Commits

Shuji Watanabe committed f493cfb

"abが同じ時間に追加された場合"テストを追加

Comments (0)

Files changed (1)

src/test/java/tddbc/lrucache/WeightListTest.java

             // Verify
             assertThat(sut.size(), is(0));
         }
-        
+
         @Test
         public void removeでaを与えるとbcを保持する() throws Exception {
             // Exercise
         }
     }
 
+    public static class abが同じ時間に追加された場合 {
+
+        private WeightList sut;
+
+        @Before
+        public void setUp() throws Exception {
+            sut = new WeightList();
+            sut.add("a", 1000);
+            sut.add("b", 1000);
+        }
+
+        @Test
+        public void removeでaを与えるとbを保持する() throws Exception {
+            // Exercise
+            sut.remove("a");
+            // Verify
+            assertThat(sut.size(), is(1));
+            assertThat(sut.get(0), is("b"));
+            assertThat(sut.getWeight("a"), is(nullValue()));
+            assertThat(sut.getWeight("b"), is(1000L));
+        }
+
+        @Test
+        public void removeLessThanで重み4000を与えると空となる() throws Exception {
+            // Exercise
+            sut.removeLessThan(4000);
+            // Verify
+            assertThat(sut.size(), is(0));
+        }
+    }
+
 }