Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 1 | #include "internal/HeaderMap.h" |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 2 | #include "internal/Config.h" |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 3 | #include <catch2/catch.hpp> |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 4 | |
| 5 | using namespace seasocks; |
| 6 | |
| 7 | namespace { |
| 8 | |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 9 | void emplace(HeaderMap& map, const char* header, const char* value) { |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 10 | map.emplace(header, value); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 11 | } |
| 12 | |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 13 | TEST_CASE("shouldConstruct", "[HeaderMapTests]") { |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 14 | HeaderMap map; |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 15 | CHECK(map.empty()); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 16 | } |
| 17 | |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 18 | TEST_CASE("shouldStoreAndRetrieve", "[HeaderMapTests]") { |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 19 | HeaderMap map; |
| 20 | emplace(map, "Foo", "Bar"); |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 21 | CHECK(map.size() == 1); |
| 22 | CHECK(map.at("Foo") == "Bar"); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 23 | emplace(map, "Baz", "Moo"); |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 24 | CHECK(map.size() == 2); |
| 25 | CHECK(map.at("Foo") == "Bar"); |
| 26 | CHECK(map.at("Baz") == "Moo"); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 27 | } |
| 28 | |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 29 | TEST_CASE("shouldBeCaseInsensitive", "[HeaderMapTests]") { |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 30 | HeaderMap map; |
| 31 | emplace(map, "Foo", "Bar"); |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 32 | CHECK(map.at("FOO") == "Bar"); |
| 33 | CHECK(map.at("foO") == "Bar"); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 36 | TEST_CASE("shouldPreserveOriginalCase", "[HeaderMapTests]") { |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 37 | HeaderMap map; |
| 38 | emplace(map, "Foo", "Bar"); |
| 39 | auto it = map.find("Foo"); |
Austin Schuh | 9d82300 | 2019-04-14 12:53:17 -0700 | [diff] [blame^] | 40 | CHECK(it->first == "Foo"); |
Austin Schuh | 24adb6b | 2015-09-06 17:37:40 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | } |