committed by
GitHub
parent
c51a97678c
commit
692eafafea
@@ -1,6 +1,7 @@
|
||||
package com.baeldung.trie;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -53,6 +54,19 @@ public class TrieTest {
|
||||
assertFalse(trie.containsNode("Programming"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenATrie_whenDeletingOverlappingElements_thenDontDeleteSubElement() {
|
||||
|
||||
Trie trie1 = new Trie();
|
||||
|
||||
trie1.insert("pie");
|
||||
trie1.insert("pies");
|
||||
|
||||
trie1.delete("pies");
|
||||
|
||||
Assertions.assertTrue(trie1.containsNode("pie"));
|
||||
}
|
||||
|
||||
private Trie createExampleTrie() {
|
||||
Trie trie = new Trie();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user