summaryrefslogtreecommitdiffstats
path: root/src/base64_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/base64_test.cc')
-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))});
}
}