summaryrefslogtreecommitdiff
path: root/asl/containers/hash_map_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/containers/hash_map_tests.cpp')
-rw-r--r--asl/containers/hash_map_tests.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/asl/containers/hash_map_tests.cpp b/asl/containers/hash_map_tests.cpp
new file mode 100644
index 0000000..6cb7fe1
--- /dev/null
+++ b/asl/containers/hash_map_tests.cpp
@@ -0,0 +1,48 @@
+#include "asl/testing/testing.hpp"
+#include "asl/containers/hash_map.hpp"
+
+ASL_TEST(default)
+{
+ asl::hash_map<int, int> map;
+
+ ASL_TEST_EXPECT(!map.contains(45));
+ ASL_TEST_EXPECT(!map.contains(46));
+
+ map.insert(45, 5);
+ map.insert(46, 6);
+
+ ASL_TEST_EXPECT(map.size() == 2);
+
+ ASL_TEST_EXPECT(map.contains(45));
+ ASL_TEST_EXPECT(map.contains(46));
+ ASL_TEST_EXPECT(!map.contains(47));
+
+ ASL_TEST_EXPECT(*map.get(45) == 5);
+ ASL_TEST_EXPECT(*map.get(46) == 6);
+ ASL_TEST_EXPECT(map.get(47) == nullptr);
+
+ ASL_TEST_EXPECT(map.remove(45));
+ ASL_TEST_EXPECT(!map.remove(45));
+
+ ASL_TEST_EXPECT(map.size() == 1);
+
+ ASL_TEST_EXPECT(!map.contains(45));
+ ASL_TEST_EXPECT(map.contains(46));
+ ASL_TEST_EXPECT(!map.contains(47));
+
+ ASL_TEST_EXPECT(map.get(45) == nullptr);
+ ASL_TEST_EXPECT(*map.get(46) == 6);
+ ASL_TEST_EXPECT(map.get(47) == nullptr);
+
+ map.insert(46, 460);
+
+ ASL_TEST_EXPECT(map.size() == 1);
+
+ ASL_TEST_EXPECT(!map.contains(45));
+ ASL_TEST_EXPECT(map.contains(46));
+ ASL_TEST_EXPECT(!map.contains(47));
+
+ ASL_TEST_EXPECT(map.get(45) == nullptr);
+ ASL_TEST_EXPECT(*map.get(46) == 460);
+ ASL_TEST_EXPECT(map.get(47) == nullptr);
+}