diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-11 16:46:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-11 16:46:30 +0000 |
commit | 8e1187a02b785e56d798660a9a292ca385e1f6aa (patch) | |
tree | b035593aa2ae37c25aeb28b537a3223c52532ab1 /src/shrpx_config_test.cc | |
parent | Adding upstream version 1.61.0. (diff) | |
download | nghttp2-ffaa6aabe1ebfc544d1fd4cd11dd12d4dc8a9c6a.tar.xz nghttp2-ffaa6aabe1ebfc544d1fd4cd11dd12d4dc8a9c6a.zip |
Adding upstream version 1.62.1.upstream/1.62.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shrpx_config_test.cc')
-rw-r--r-- | src/shrpx_config_test.cc | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/shrpx_config_test.cc b/src/shrpx_config_test.cc index 068f185..9e08f81 100644 --- a/src/shrpx_config_test.cc +++ b/src/shrpx_config_test.cc @@ -35,6 +35,8 @@ #include "shrpx_config.h" #include "shrpx_log.h" +using namespace std::literals; + namespace shrpx { namespace { @@ -54,32 +56,32 @@ const MunitSuite config_suite{ void test_shrpx_config_parse_header(void) { BlockAllocator balloc(4096, 4096); - auto p = parse_header(balloc, StringRef::from_lit("a: b")); - assert_stdstring_equal("a", p.name.str()); - assert_stdstring_equal("b", p.value.str()); + auto p = parse_header(balloc, "a: b"_sr); + assert_stdsv_equal("a"sv, p.name); + assert_stdsv_equal("b"sv, p.value); - p = parse_header(balloc, StringRef::from_lit("a: b")); - assert_stdstring_equal("a", p.name.str()); - assert_stdstring_equal("b", p.value.str()); + p = parse_header(balloc, "a: b"_sr); + assert_stdsv_equal("a"sv, p.name); + assert_stdsv_equal("b"sv, p.value); - p = parse_header(balloc, StringRef::from_lit(":a: b")); + p = parse_header(balloc, ":a: b"_sr); assert_true(p.name.empty()); - p = parse_header(balloc, StringRef::from_lit("a: :b")); - assert_stdstring_equal("a", p.name.str()); - assert_stdstring_equal(":b", p.value.str()); + p = parse_header(balloc, "a: :b"_sr); + assert_stdsv_equal("a"sv, p.name); + assert_stdsv_equal(":b"sv, p.value); - p = parse_header(balloc, StringRef::from_lit(": b")); + p = parse_header(balloc, ": b"_sr); assert_true(p.name.empty()); - p = parse_header(balloc, StringRef::from_lit("alpha: bravo charlie")); - assert_stdstring_equal("alpha", p.name.str()); - assert_stdstring_equal("bravo charlie", p.value.str()); + p = parse_header(balloc, "alpha: bravo charlie"_sr); + assert_stdsv_equal("alpha", p.name); + assert_stdsv_equal("bravo charlie", p.value); - p = parse_header(balloc, StringRef::from_lit("a,: b")); + p = parse_header(balloc, "a,: b"_sr); assert_true(p.name.empty()); - p = parse_header(balloc, StringRef::from_lit("a: b\x0a")); + p = parse_header(balloc, "a: b\x0a"_sr); assert_true(p.name.empty()); } @@ -87,91 +89,90 @@ void test_shrpx_config_parse_log_format(void) { BlockAllocator balloc(4096, 4096); auto res = parse_log_format( - balloc, StringRef::from_lit( - R"($remote_addr - $remote_user [$time_local] )" - R"("$request" $status $body_bytes_sent )" - R"("${http_referer}" $http_host "$http_user_agent")")); + balloc, R"($remote_addr - $remote_user [$time_local] )" + R"("$request" $status $body_bytes_sent )" + R"("${http_referer}" $http_host "$http_user_agent")"_sr); assert_size(16, ==, res.size()); assert_enum_class(LogFragmentType::REMOTE_ADDR, ==, res[0].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[1].type); - assert_stdstring_equal(" - $remote_user [", res[1].value.str()); + assert_stdsv_equal(" - $remote_user ["sv, res[1].value); assert_enum_class(LogFragmentType::TIME_LOCAL, ==, res[2].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[3].type); - assert_stdstring_equal("] \"", res[3].value.str()); + assert_stdsv_equal("] \""sv, res[3].value); assert_enum_class(LogFragmentType::REQUEST, ==, res[4].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[5].type); - assert_stdstring_equal("\" ", res[5].value.str()); + assert_stdsv_equal("\" "sv, res[5].value); assert_enum_class(LogFragmentType::STATUS, ==, res[6].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[7].type); - assert_stdstring_equal(" ", res[7].value.str()); + assert_stdsv_equal(" "sv, res[7].value); assert_enum_class(LogFragmentType::BODY_BYTES_SENT, ==, res[8].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[9].type); - assert_stdstring_equal(" \"", res[9].value.str()); + assert_stdsv_equal(" \""sv, res[9].value); assert_enum_class(LogFragmentType::HTTP, ==, res[10].type); - assert_stdstring_equal("referer", res[10].value.str()); + assert_stdsv_equal("referer"sv, res[10].value); assert_enum_class(LogFragmentType::LITERAL, ==, res[11].type); - assert_stdstring_equal("\" ", res[11].value.str()); + assert_stdsv_equal("\" "sv, res[11].value); assert_enum_class(LogFragmentType::AUTHORITY, ==, res[12].type); assert_enum_class(LogFragmentType::LITERAL, ==, res[13].type); - assert_stdstring_equal(" \"", res[13].value.str()); + assert_stdsv_equal(" \""sv, res[13].value); assert_enum_class(LogFragmentType::HTTP, ==, res[14].type); - assert_stdstring_equal("user-agent", res[14].value.str()); + assert_stdsv_equal("user-agent"sv, res[14].value); assert_enum_class(LogFragmentType::LITERAL, ==, res[15].type); - assert_stdstring_equal("\"", res[15].value.str()); + assert_stdsv_equal("\""sv, res[15].value); - res = parse_log_format(balloc, StringRef::from_lit("$")); + res = parse_log_format(balloc, "$"_sr); assert_size(1, ==, res.size()); assert_enum_class(LogFragmentType::LITERAL, ==, res[0].type); - assert_stdstring_equal("$", res[0].value.str()); + assert_stdsv_equal("$"sv, res[0].value); - res = parse_log_format(balloc, StringRef::from_lit("${")); + res = parse_log_format(balloc, "${"_sr); assert_size(1, ==, res.size()); assert_enum_class(LogFragmentType::LITERAL, ==, res[0].type); - assert_stdstring_equal("${", res[0].value.str()); + assert_stdsv_equal("${"sv, res[0].value); - res = parse_log_format(balloc, StringRef::from_lit("${a")); + res = parse_log_format(balloc, "${a"_sr); assert_size(1, ==, res.size()); assert_enum_class(LogFragmentType::LITERAL, ==, res[0].type); - assert_stdstring_equal("${a", res[0].value.str()); + assert_stdsv_equal("${a"sv, res[0].value); - res = parse_log_format(balloc, StringRef::from_lit("${a ")); + res = parse_log_format(balloc, "${a "_sr); assert_size(1, ==, res.size()); assert_enum_class(LogFragmentType::LITERAL, ==, res[0].type); - assert_stdstring_equal("${a ", res[0].value.str()); + assert_stdsv_equal("${a "sv, res[0].value); - res = parse_log_format(balloc, StringRef::from_lit("$$remote_addr")); + res = parse_log_format(balloc, "$$remote_addr"_sr); assert_size(2, ==, res.size()); assert_enum_class(LogFragmentType::LITERAL, ==, res[0].type); - assert_stdstring_equal("$", res[0].value.str()); + assert_stdsv_equal("$"sv, res[0].value); assert_enum_class(LogFragmentType::REMOTE_ADDR, ==, res[1].type); - assert_stdstring_equal("", res[1].value.str()); + assert_stdsv_equal(""sv, res[1].value); } void test_shrpx_config_read_tls_ticket_key_file(void) { |