summaryrefslogtreecommitdiff
path: root/asl/tests/hash_set_tests.cpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-15 23:50:56 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-15 23:50:56 +0100
commit0ee5725793f62e6b0386b66d21aee5eebfd7be13 (patch)
treece0c3159ce002810606ac40068a0425697a7cb3b /asl/tests/hash_set_tests.cpp
parent83b856b7d42deba868608f323a3cec4ae6a17d90 (diff)
Add copy & move for hash_set
Diffstat (limited to 'asl/tests/hash_set_tests.cpp')
-rw-r--r--asl/tests/hash_set_tests.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/asl/tests/hash_set_tests.cpp b/asl/tests/hash_set_tests.cpp
index 9df9463..56cb07a 100644
--- a/asl/tests/hash_set_tests.cpp
+++ b/asl/tests/hash_set_tests.cpp
@@ -134,3 +134,52 @@ ASL_TEST(destructor_and_remove)
}
}
+ASL_TEST(copy)
+{
+ asl::hash_set<int> set1;
+
+ for (int i = 0; i < 100; ++i)
+ {
+ set1.insert(i);
+ }
+
+ asl::hash_set<int> set2 = set1;
+ asl::hash_set<int> set3;
+ set3 = set1;
+
+ ASL_TEST_EXPECT(set2.size() == 100);
+ ASL_TEST_EXPECT(set3.size() == 100);
+
+ for (int i = 0; i < 100; ++i)
+ {
+ ASL_TEST_EXPECT(set2.contains(i));
+ ASL_TEST_EXPECT(set3.contains(i));
+ }
+}
+
+ASL_TEST(move)
+{
+ asl::hash_set<int> set1;
+
+ for (int i = 0; i < 100; ++i)
+ {
+ set1.insert(i);
+ }
+
+ asl::hash_set<int> set2 = ASL_MOVE(set1);
+
+ ASL_TEST_EXPECT(set2.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ {
+ ASL_TEST_EXPECT(set2.contains(i));
+ }
+
+ set1 = ASL_MOVE(set2);
+
+ ASL_TEST_EXPECT(set1.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ {
+ ASL_TEST_EXPECT(set1.contains(i));
+ }
+}
+