aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/trie.h (renamed from trie.cc)27
-rw-r--r--test.cc24
2 files changed, 28 insertions, 23 deletions
diff --git a/trie.cc b/src/trie.h
index f002399..9134c45 100644
--- a/trie.cc
+++ b/src/trie.h
@@ -1,10 +1,9 @@
-#include <cstdint>
+#ifndef TRIE_SRC_TRIE_H_
+#define TRIE_SRC_TRIE_H_
+
#include <vector>
#include <map>
-#include <cassert>
-#include <iostream>
-
template <
typename Key
>
@@ -92,22 +91,4 @@ class Trie {
};
-int main() {
- Trie<uint8_t> test;
-
- test.add({1, 2, 3});
- test.add({1, 2, 4});
- test.add({2, 1});
- test.add({2, 1, 1});
-
- assert(test.resolve({1, 2}).second != nullptr);
- assert(test.resolve({1, 2, 3}).second != nullptr);
- assert(test.resolve({1, 2, 4}).second != nullptr);
- assert(test.resolve({3}).second == nullptr);
-
- test.remove({1, 2});
-
- assert(test.resolve({1, 2, 4}).second == nullptr);
- assert(test.resolve({1, 2, 3}).second == nullptr);
- assert(test.resolve({1, 2}).second == nullptr);
-}
+#endif // TRIE_SRC_TRIE_H_
diff --git a/test.cc b/test.cc
new file mode 100644
index 0000000..5105f09
--- /dev/null
+++ b/test.cc
@@ -0,0 +1,24 @@
+#include "trie.h"
+
+#include <cassert>
+#include <cstdint>
+
+int main() {
+ Trie<uint8_t> test;
+
+ test.add({1, 2, 3});
+ test.add({1, 2, 4});
+ test.add({2, 1});
+ test.add({2, 1, 1});
+
+ assert(test.resolve({1, 2}).second != nullptr);
+ assert(test.resolve({1, 2, 3}).second != nullptr);
+ assert(test.resolve({1, 2, 4}).second != nullptr);
+ assert(test.resolve({3}).second == nullptr);
+
+ test.remove({1, 2});
+
+ assert(test.resolve({1, 2, 4}).second == nullptr);
+ assert(test.resolve({1, 2, 3}).second == nullptr);
+ assert(test.resolve({1, 2}).second == nullptr);
+}