|
31 | 31 | package org.scijava.parsington.eval; |
32 | 32 |
|
33 | 33 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 34 | +import static org.junit.jupiter.api.Assertions.assertNull; |
34 | 35 | import static org.junit.jupiter.api.Assertions.assertThrows; |
35 | 36 | import static org.junit.jupiter.api.Assertions.assertTrue; |
36 | 37 |
|
@@ -64,6 +65,30 @@ public void testGetSet() { |
64 | 65 | assertEquals("hello", e.get("x")); |
65 | 66 | } |
66 | 67 |
|
| 68 | + /** Tests {@link Evaluator#remove(String)}. */ |
| 69 | + @Test |
| 70 | + public void testRemove() { |
| 71 | + final Evaluator e = createEvaluator(); |
| 72 | + // Removing an absent variable returns null. |
| 73 | + assertNull(e.remove("x")); |
| 74 | + e.set("x", 99); |
| 75 | + assertEquals(99, e.remove("x")); |
| 76 | + // Variable is gone after removal. |
| 77 | + assertThrows(IllegalArgumentException.class, () -> e.get("x")); |
| 78 | + } |
| 79 | + |
| 80 | + /** Tests {@link Evaluator#clear()}. */ |
| 81 | + @Test |
| 82 | + public void testClear() { |
| 83 | + final Evaluator e = createEvaluator(); |
| 84 | + e.set("a", 1); |
| 85 | + e.set("b", 2); |
| 86 | + e.clear(); |
| 87 | + assertEquals(new HashMap<>(), e.getAll()); |
| 88 | + assertThrows(IllegalArgumentException.class, () -> e.get("a")); |
| 89 | + assertThrows(IllegalArgumentException.class, () -> e.get("b")); |
| 90 | + } |
| 91 | + |
67 | 92 | /** Tests {@link Evaluator#getAll()} and {@link Evaluator#setAll(Map)}. */ |
68 | 93 | @Test |
69 | 94 | public void testGetAllSetAll() { |
|
0 commit comments