Commits

Anonymous committed b16b496

add size_greater_than_max

  • Participants
  • Parent commits eb77180

Comments (0)

Files changed (2)

File src/main/java/tddbc/LRUCache.java

     }
 
     public int getSize() {
-        return container.size();
+        return Math.min(container.size(), cacheSize);
     }
 
 }

File src/test/java/tddbc/LRUCacheTest.java

         target.put("c", "dataC");
         assertThat(target.getSize(), is(3));
     }
+
+    @Test
+    public void size_greater_than_max() throws Exception {
+        target.put("a", "dataA");
+        target.put("b", "dataB");
+        target.put("c", "dataC");
+        target.put("d", "dataD");
+        assertThat(target.getSize(), is(3));
+    }
+
 }