diff options
author | kaiwu <kaiwu2004@gmail.com> | 2022-04-17 09:33:20 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2022-04-17 09:33:20 +0800 |
commit | 096c7e2226bfd45a98a4f3aae25f6394cb89cd22 (patch) | |
tree | d4acfb924628fe54ffc2a88b2a0d69bb55b6150d /test/test_common.cpp | |
parent | 665395fdc148c32bdb3226030ce0616ba2c9540f (diff) | |
download | advent-of-code-096c7e2226bfd45a98a4f3aae25f6394cb89cd22.tar.gz advent-of-code-096c7e2226bfd45a98a4f3aae25f6394cb89cd22.zip |
add wyhash
Diffstat (limited to 'test/test_common.cpp')
-rw-r--r-- | test/test_common.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/test_common.cpp b/test/test_common.cpp index 1486988..06f445a 100644 --- a/test/test_common.cpp +++ b/test/test_common.cpp @@ -1,7 +1,8 @@ #include "catch.hpp" #include "common.h" +#include <unordered_map> -TEST_CASE("load file", "[]") { +TEST_CASE("load file", "[common]") { line_view file{"\n111\n2222\n33333\n\n", 17}; const char* lines[] = {"\n", "111\n", "2222\n", "33333\n", "\n"}; int i = 0; @@ -14,7 +15,7 @@ TEST_CASE("load file", "[]") { lines); } -TEST_CASE("char count", "[]") { +TEST_CASE("char count", "[common]") { line_view line{"accad1\n", 7}; ascii_count ac{line}; REQUIRE(ac['\n'] == 1); @@ -23,3 +24,10 @@ TEST_CASE("char count", "[]") { REQUIRE(ac['d'] == 1); REQUIRE(ac['1'] == 1); } + +TEST_CASE("line_view hash", "[common]") { + std::unordered_map<line_view, int> h{{"abc", 1}, {"xyz", 2}}; + REQUIRE(h["abc"] == 1); + REQUIRE(h["xyz"] == 2); + REQUIRE(h.find("ab") == h.end()); +} |