MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestTrieInsert_substrings

Function TestTrieInsert_substrings

structure/trie/trie_test.go:27–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestTrieInsert_substrings(t *testing.T) {
28 n := NewNode()
29
30 insertWords := []string{
31 "aa",
32 "aaaa",
33 "aaaaa",
34 }
35
36 checkWords := map[string]bool{
37 "a": false,
38 "aa": true,
39 "aaa": false,
40 "aaaa": true,
41 "aaaaa": true,
42 "aaaaaa": false,
43 "aaaaaaa": false,
44 }
45
46 n.Insert(insertWords...)
47 n.verify(t, checkWords)
48 n.verifySizeCapa(t, 3, 5+1)
49
50 n.Remove("aaaa")
51 checkWords["aaaa"] = false
52 n.verify(t, checkWords)
53 n.verifySizeCapa(t, 2, 5+1)
54
55 if n.Compact() {
56 t.Fatalf("it should not be possible to remove the node")
57 }
58 n.verify(t, checkWords)
59 n.verifySizeCapa(t, 2, 5+1)
60}
61
62func TestTrieRemove(t *testing.T) {
63 n := NewNode()

Callers

nothing calls this directly

Calls 6

InsertMethod · 0.95
verifyMethod · 0.95
verifySizeCapaMethod · 0.95
RemoveMethod · 0.95
CompactMethod · 0.95
NewNodeFunction · 0.70

Tested by

no test coverage detected