26 lines
669 B
C++
26 lines
669 B
C++
|
#ifdef TESTS_BUILD
|
||
|
#include <cstring>
|
||
|
#include <unordered_map>
|
||
|
#include "../extern/catch.hpp"
|
||
|
#include "../src/ConstString.hpp"
|
||
|
|
||
|
TEST_CASE("Use const string in unordered_map", "[Utilities]") {
|
||
|
std::unordered_map<Arbutils::ConstString, int32_t> map;
|
||
|
map.insert({"foo"_c, 1});
|
||
|
map.insert({"bar"_c, 5});
|
||
|
|
||
|
CHECK(map["bar"_c] == 5);
|
||
|
CHECK(map["foo"_c] == 1);
|
||
|
}
|
||
|
|
||
|
TEST_CASE("Use const string in switch case", "[Utilities]") {
|
||
|
auto val = Arbutils::ConstString("foobar");
|
||
|
switch (val){
|
||
|
case "foo"_c: FAIL(); break;
|
||
|
case "bar"_c: FAIL(); break;
|
||
|
case "foobar"_c: SUCCEED(); break;
|
||
|
default: FAIL(); break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|