1. Shuji Watanabe
  2. tddbc-sapporo2.2

Commits

Shuji Watanabe  committed b6b66ac

"removeFirstするとaがmapから削除されている"のテストを追加

  • Participants
  • Parent commits ae70f89
  • Branches default

Comments (0)

Files changed (2)

File src/main/java/tddbc/lrucache/WeightContainer.java

View file
         }
     }
 
+    public void removeFirst() {
+        Long w = this.map.firstKey();
+        LinkedList<String> l = this.map.get(w);
+        String e = l.removeFirst();
+        if (l.isEmpty()){
+            this.map.remove(w);
+        }
+        this.weights.remove(e);
+        this.list.remove(e);
+    }
+
 }

File src/test/java/tddbc/lrucache/WeightContainerTest.java

View file
             assertThat(sut.map.get(3000L).contains("a"), is(true));
         }
 
+        @Test
+        public void removeFirstするとaがmapから削除されている() throws Exception {
+            // SetUp
+            // Exercise
+            sut.removeFirst();
+            // Verify
+            assertThat(sut.size(), is(1));
+            assertThat(sut.get(0), is("b"));
+            assertThat(sut.getWeight("a"), is(nullValue()));
+            assertThat(sut.getWeight("b"), is(2000L));
+            assertThat(sut.map.get(1000L), is(nullValue()));
+            assertThat(sut.map.get(2000L).get(0), is("b"));
+            
         
+            
+        }
     }
 
     public static class abcが追加された場合 {