summaryrefslogtreecommitdiffstats
path: root/src/base64_test.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-11 16:46:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-11 16:46:30 +0000
commit8e1187a02b785e56d798660a9a292ca385e1f6aa (patch)
treeb035593aa2ae37c25aeb28b537a3223c52532ab1 /src/base64_test.cc
parentAdding upstream version 1.61.0. (diff)
downloadnghttp2-8e1187a02b785e56d798660a9a292ca385e1f6aa.tar.xz
nghttp2-8e1187a02b785e56d798660a9a292ca385e1f6aa.zip
Adding upstream version 1.62.1.upstream/1.62.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/base64_test.cc71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/base64_test.cc b/src/base64_test.cc
index 9ab770f..0aeadf7 100644
--- a/src/base64_test.cc
+++ b/src/base64_test.cc
@@ -33,6 +33,8 @@
#include "base64.h"
+using namespace std::literals;
+
namespace nghttp2 {
namespace {
@@ -73,67 +75,68 @@ void test_base64_encode(void) {
void test_base64_decode(void) {
BlockAllocator balloc(4096, 4096);
{
- std::string in = "/w==";
+ auto in = "/w=="sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("\xff", out);
- assert_stdstring_equal(
- "\xff", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal("\xff"sv, out);
+ assert_stdsv_equal("\xff"sv, StringRef{base64::decode(
+ balloc, std::begin(in), std::end(in))});
}
{
- std::string in = "//4=";
+ auto in = "//4="sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("\xff\xfe", out);
- assert_stdstring_equal(
- "\xff\xfe", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal("\xff\xfe"sv, out);
+ assert_stdsv_equal(
+ "\xff\xfe"sv,
+ StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
- std::string in = "//79";
+ auto in = "//79"sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("\xff\xfe\xfd", out);
- assert_stdstring_equal(
- "\xff\xfe\xfd",
- base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal("\xff\xfe\xfd"sv, out);
+ assert_stdsv_equal(
+ "\xff\xfe\xfd"sv,
+ StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
- std::string in = "//79/A==";
+ auto in = "//79/A=="sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("\xff\xfe\xfd\xfc", out);
- assert_stdstring_equal(
- "\xff\xfe\xfd\xfc",
- base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal("\xff\xfe\xfd\xfc"sv, out);
+ assert_stdsv_equal(
+ "\xff\xfe\xfd\xfc"sv,
+ StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
// we check the number of valid input must be multiples of 4
- std::string in = "//79=";
+ auto in = "//79="sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("", out);
- assert_stdstring_equal(
- "", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal(""sv, out);
+ assert_stdsv_equal(
+ ""sv, StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
// ending invalid character at the boundary of multiples of 4 is
// bad
- std::string in = "bmdodHRw\n";
+ auto in = "bmdodHRw\n"sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("", out);
- assert_stdstring_equal(
- "", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal("", out);
+ assert_stdsv_equal(
+ ""sv, StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
// after seeing '=', subsequent input must be also '='.
- std::string in = "//79/A=A";
+ auto in = "//79/A=A"sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("", out);
- assert_stdstring_equal(
- "", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal(""sv, out);
+ assert_stdsv_equal(
+ ""sv, StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
{
// additional '=' at the end is bad
- std::string in = "//79/A======";
+ auto in = "//79/A======"sv;
auto out = base64::decode(std::begin(in), std::end(in));
- assert_stdstring_equal("", out);
- assert_stdstring_equal(
- "", base64::decode(balloc, std::begin(in), std::end(in)).str());
+ assert_stdsv_equal(""sv, out);
+ assert_stdsv_equal(
+ ""sv, StringRef{base64::decode(balloc, std::begin(in), std::end(in))});
}
}