aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-02-04 19:10:11 +0100
committerAdrian Kummerländer2014-02-04 19:10:11 +0100
commit8d1661ea333f15ddc2dde3b2a25288d1ccf485d9 (patch)
tree77137bc4739d5c18272cc30ee96bf6969626ab70
parente0028fb5303218feebe61b2cd93d4601c40fde79 (diff)
downloadTrie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.gz
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.bz2
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.lz
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.xz
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.zst
Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.zip
Moved Trie template into src directory
* renamed trie.cc to test.cc in preparation for implementing GoogleTest based test cases
-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);
+}