1. Shuji Watanabe
  2. tddbc-sapporo

Commits

shuji.w6e  committed b16b496

add size_greater_than_max

  • Participants
  • Parent commits eb77180
  • Branches default

Comments (0)

Files changed (2)

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

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

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

View file
         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));
+    }
+
 }