Skip to content

Commit fa115fa

Browse files
committed
PrefServiceTest: add tests for clear and remove
This verifies that the previous commit improves behavior.
1 parent 967ac72 commit fa115fa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/org/scijava/prefs/PrefServiceTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,25 @@ public void testList() {
175175
assertEquals(recentFiles, result);
176176
}
177177

178+
@Test
179+
public void testClear() {
180+
prefService.put(getClass(), "dog", "lazy");
181+
prefService.put(getClass(), "fox", "quick");
182+
assertEquals("lazy", prefService.get(getClass(), "dog"));
183+
assertEquals("quick", prefService.get(getClass(), "fox"));
184+
prefService.clear(getClass());
185+
assertNull(prefService.get(getClass(), "dog"));
186+
assertNull(prefService.get(getClass(), "fox"));
187+
}
188+
189+
@Test
190+
public void testRemove() {
191+
prefService.put(getClass(), "hello", "world");
192+
assertEquals("world", prefService.get(getClass(), "hello"));
193+
prefService.remove(getClass(), "hello");
194+
assertNull(prefService.get(getClass(), "hello"));
195+
}
196+
178197
/**
179198
* The Java Preferences API does not support keys longer than 80 characters.
180199
* Let's test that our service does not fall victim to this limitation.

0 commit comments

Comments
 (0)