aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/kstd/string.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd/kstd/string.test.cpp')
-rw-r--r--libs/kstd/kstd/string.test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/libs/kstd/kstd/string.test.cpp b/libs/kstd/kstd/string.test.cpp
index 3fbf6c0c..2de8b513 100644
--- a/libs/kstd/kstd/string.test.cpp
+++ b/libs/kstd/kstd/string.test.cpp
@@ -8,9 +8,11 @@
#include <algorithm>
#include <cstring>
#include <forward_list>
+#include <functional>
#include <iterator>
#include <memory>
#include <sstream>
+#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
@@ -2942,3 +2944,36 @@ SCENARIO("String iteration", "[string]")
}
}
}
+
+SCENARIO("String STL integration", "[string]")
+{
+ GIVEN("An empty string")
+ {
+ auto s = kstd::string{""};
+
+ WHEN("hashing the string")
+ {
+ auto hash_result = std::hash<kstd::string>{}(s);
+
+ THEN("the result is equal to hashing an empty std::string")
+ {
+ REQUIRE(hash_result == std::hash<std::string>{}(""));
+ }
+ }
+ }
+
+ GIVEN("A non-empty string")
+ {
+ auto s = kstd::string{"abcd"};
+
+ WHEN("hashing the string")
+ {
+ auto hash_result = std::hash<kstd::string>{}(s);
+
+ THEN("the result is equal to hashing the same std::string")
+ {
+ REQUIRE(hash_result == std::hash<std::string>{}("abcd"));
+ }
+ }
+ }
+}