29 #include <gtest/gtest.h>
40 static inline uint32_t *ptr(uintptr_t
val)
42 return (uint32_t *)
val;
64 EXPECT_EQ(trie.lookup(0x123456701234567),
nullptr) << dumpTrie();
69 trie.insert(0x0123456789abcdef, 40, ptr(1));
70 EXPECT_EQ(trie.lookup(0x123456701234567),
nullptr) << dumpTrie();
71 EXPECT_EQ(trie.lookup(0x123456789ab0000), ptr(1)) << dumpTrie();
76 trie.insert(0x0123456789abcdef, 40, ptr(1));
77 trie.insert(0x0123456789abcdef, 36, ptr(2));
78 EXPECT_EQ(trie.lookup(0x123456700000000),
nullptr) << dumpTrie();
79 EXPECT_EQ(trie.lookup(0x123456789ab0000), ptr(2)) << dumpTrie();
84 trie.insert(0x0123456789abcdef, 36, ptr(2));
85 trie.insert(0x0123456789abcdef, 40, ptr(1));
86 EXPECT_EQ(trie.lookup(0x123456700000000),
nullptr) << dumpTrie();
87 EXPECT_EQ(trie.lookup(0x123456789ab0000), ptr(2)) << dumpTrie();
92 trie.insert(0x0123456789abcdef, 40, ptr(2));
93 trie.insert(0x0123456776543210, 40, ptr(1));
94 EXPECT_EQ(trie.lookup(0x0123456789000000), ptr(2)) << dumpTrie();
95 EXPECT_EQ(trie.lookup(0x0123456776000000), ptr(1)) << dumpTrie();
96 EXPECT_EQ(trie.lookup(0x0123456700000000),
nullptr) << dumpTrie();
101 trie.insert(0x0123456789000000, 40, ptr(4));
102 trie.insert(0x0123000000000000, 40, ptr(1));
103 trie.insert(0x0123456780000000, 40, ptr(3));
104 trie.insert(0x0123456700000000, 40, ptr(2));
106 EXPECT_EQ(trie.lookup(0x0123000000000000), ptr(1)) << dumpTrie();
107 EXPECT_EQ(trie.lookup(0x0123456700000000), ptr(2)) << dumpTrie();
108 EXPECT_EQ(trie.lookup(0x0123456780000000), ptr(3)) << dumpTrie();
109 EXPECT_EQ(trie.lookup(0x0123456789000000), ptr(4)) << dumpTrie();
114 TrieType::Handle node1, node2;
115 trie.insert(0x0123456789000000, 40, ptr(4));
116 trie.insert(0x0123000000000000, 40, ptr(1));
117 trie.insert(0x0123456780000000, 40, ptr(3));
118 node1 = trie.insert(0x0123456700000000, 40, ptr(2));
119 node2 = trie.insert(0x0123456700000000, 32, ptr(10));
121 EXPECT_EQ(trie.lookup(0x0123000000000000), ptr(1)) << dumpTrie();
122 EXPECT_EQ(trie.lookup(0x0123456700000000), ptr(10)) << dumpTrie();
123 EXPECT_EQ(trie.lookup(0x0123456780000000), ptr(10)) << dumpTrie();
124 EXPECT_EQ(trie.lookup(0x0123456789000000), ptr(10)) << dumpTrie();
128 EXPECT_EQ(trie.lookup(0x0123000000000000), ptr(1)) << dumpTrie();
129 EXPECT_EQ(trie.lookup(0x0123456700000000), ptr(2)) << dumpTrie();
130 EXPECT_EQ(trie.lookup(0x0123456780000000), ptr(3)) << dumpTrie();
131 EXPECT_EQ(trie.lookup(0x0123456789000000), ptr(4)) << dumpTrie();
135 EXPECT_EQ(trie.lookup(0x0123000000000000), ptr(1)) << dumpTrie();
136 EXPECT_EQ(trie.lookup(0x0123456700000000),
nullptr) << dumpTrie();
137 EXPECT_EQ(trie.lookup(0x0123456780000000), ptr(3)) << dumpTrie();
138 EXPECT_EQ(trie.lookup(0x0123456789000000), ptr(4)) << dumpTrie();