MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / sanityClearTest

Method sanityClearTest

lab07/tests/TestBSTMap.java:22–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20
21 // This test assumes put/size/containsKey/get are implemented properly.
22 @Test
23 public void sanityClearTest() {
24 BSTMap<String, Integer> b = new BSTMap<>();
25 for (int i = 0; i < 455; i++) {
26 b.put("hi" + i, 1+i);
27 //make sure put is working via containsKey and get
28 assertThat(b.get("hi" + i)).isEqualTo(1 + i);
29 assertThat(b.containsKey("hi" + i)).isTrue();
30 }
31 assertThat(b.size()).isEqualTo(455);
32 b.clear();
33 assertThat(b.size()).isEqualTo(0);
34 for (int i = 0; i < 455; i++) {
35 assertThat(b.get("hi" + i)).isNull();
36 assertThat(b.containsKey("hi" + i)).isFalse();
37 }
38 }
39
40 // Assumes `put` is implemented properly.
41 @Test

Callers

nothing calls this directly

Calls 5

putMethod · 0.65
getMethod · 0.65
containsKeyMethod · 0.65
sizeMethod · 0.65
clearMethod · 0.65

Tested by

no test coverage detected