aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/base64
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:23 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:23 +0300
commit706b83ed7de5a473436620367af31fc0ceecde07 (patch)
tree103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/string_utils/base64
parent918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff)
downloadydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils/base64')
-rw-r--r--library/cpp/string_utils/base64/base64.cpp4
-rw-r--r--library/cpp/string_utils/base64/base64.h26
-rw-r--r--library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp72
-rw-r--r--library/cpp/string_utils/base64/base64_ut.cpp98
-rw-r--r--library/cpp/string_utils/base64/bench/main.cpp18
-rw-r--r--library/cpp/string_utils/base64/ut/ya.make2
6 files changed, 110 insertions, 110 deletions
diff --git a/library/cpp/string_utils/base64/base64.cpp b/library/cpp/string_utils/base64/base64.cpp
index 05c201f0de..d240f1c112 100644
--- a/library/cpp/string_utils/base64/base64.cpp
+++ b/library/cpp/string_utils/base64/base64.cpp
@@ -245,13 +245,13 @@ size_t Base64Decode(void* dst, const char* b, const char* e) {
return outLen;
}
-TString Base64DecodeUneven(const TStringBuf s) {
+TString Base64DecodeUneven(const TStringBuf s) {
if (s.length() % 4 == 0) {
return Base64Decode(s);
}
// padding to 4
- return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '='));
+ return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '='));
}
char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) {
diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h
index f778a6425a..6c6d2d9f08 100644
--- a/library/cpp/string_utils/base64/base64.h
+++ b/library/cpp/string_utils/base64/base64.h
@@ -27,14 +27,14 @@ inline TStringBuf Base64Decode(const TStringBuf src, void* dst) {
return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end()));
}
-inline void Base64Decode(const TStringBuf src, TString& dst) {
+inline void Base64Decode(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64DecodeBufSize(src.size()));
dst.resize(Base64Decode(src, dst.begin()).size());
}
//WARNING: can process not whole input silently, use Base64StrictDecode instead of this function
-inline TString Base64Decode(const TStringBuf s) {
- TString ret;
+inline TString Base64Decode(const TStringBuf s) {
+ TString ret;
Base64Decode(s, ret);
return ret;
}
@@ -71,7 +71,7 @@ inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) {
/// @param src a base64 encoded string.
/// @param dst a decoded string.
///
-inline void Base64StrictDecode(const TStringBuf src, TString& dst) {
+inline void Base64StrictDecode(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64DecodeBufSize(src.size()));
dst.resize(Base64StrictDecode(src, dst.begin()).size());
}
@@ -81,15 +81,15 @@ inline void Base64StrictDecode(const TStringBuf src, TString& dst) {
///
/// @returns a decoded string.
///
-inline TString Base64StrictDecode(const TStringBuf src) {
- TString ret;
+inline TString Base64StrictDecode(const TStringBuf src) {
+ TString ret;
Base64StrictDecode(src, ret);
return ret;
}
/// @}
/// Works with strings which length is not divisible by 4.
-TString Base64DecodeUneven(const TStringBuf s);
+TString Base64DecodeUneven(const TStringBuf s);
//encode
constexpr size_t Base64EncodeBufSize(const size_t len) noexcept {
@@ -107,24 +107,24 @@ inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) {
return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size()));
}
-inline void Base64Encode(const TStringBuf src, TString& dst) {
+inline void Base64Encode(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64EncodeBufSize(src.size()));
dst.resize(Base64Encode(src, dst.begin()).size());
}
-inline void Base64EncodeUrl(const TStringBuf src, TString& dst) {
+inline void Base64EncodeUrl(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64EncodeBufSize(src.size()));
dst.resize(Base64EncodeUrl(src, dst.begin()).size());
}
-inline TString Base64Encode(const TStringBuf s) {
- TString ret;
+inline TString Base64Encode(const TStringBuf s) {
+ TString ret;
Base64Encode(s, ret);
return ret;
}
-inline TString Base64EncodeUrl(const TStringBuf s) {
- TString ret;
+inline TString Base64EncodeUrl(const TStringBuf s) {
+ TString ret;
Base64EncodeUrl(s, ret);
return ret;
}
diff --git a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
index c3ed068a37..ae665091e7 100644
--- a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
+++ b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
@@ -2,45 +2,45 @@
#include <library/cpp/string_utils/base64/base64.h>
-Y_UNIT_TEST_SUITE(TBase64DecodeUneven) {
- Y_UNIT_TEST(Base64DecodeUneven) {
- const TString wikipedia_slogan =
- "Man is distinguished, not only by his reason, "
- "but by this singular passion from other animals, which is a lust of the "
- "mind, that by a perseverance of delight in the continued and "
- "indefatigable generation of knowledge, exceeds the short "
- "vehemence of any carnal pleasure.";
- const TString encoded =
- "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
- "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
- "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
- "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
- "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
+Y_UNIT_TEST_SUITE(TBase64DecodeUneven) {
+ Y_UNIT_TEST(Base64DecodeUneven) {
+ const TString wikipedia_slogan =
+ "Man is distinguished, not only by his reason, "
+ "but by this singular passion from other animals, which is a lust of the "
+ "mind, that by a perseverance of delight in the continued and "
+ "indefatigable generation of knowledge, exceeds the short "
+ "vehemence of any carnal pleasure.";
+ const TString encoded =
+ "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
+ "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
+ "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
+ "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
+ "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
- UNIT_ASSERT_VALUES_EQUAL(encoded, Base64Encode(wikipedia_slogan));
- UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded));
+ UNIT_ASSERT_VALUES_EQUAL(encoded, Base64Encode(wikipedia_slogan));
+ UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded));
- const TString encoded_url1 =
- "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
- "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
- "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
- "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
- "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4,";
- const TString encoded_url2 =
- "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
- "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
- "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
- "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
- "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4";
- UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url1));
- UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url2));
+ const TString encoded_url1 =
+ "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
+ "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
+ "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
+ "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
+ "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4,";
+ const TString encoded_url2 =
+ "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
+ "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1"
+ "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
+ "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
+ "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4";
+ UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url1));
+ UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url2));
- const TString lp = "Linkin Park";
- UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64Encode(lp)));
- UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64EncodeUrl(lp)));
+ const TString lp = "Linkin Park";
+ UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64Encode(lp)));
+ UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64EncodeUrl(lp)));
- const TString dp = "ADP GmbH\nAnalyse Design & Programmierung\nGesellschaft mit beschränkter Haftung";
- UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64Encode(dp)));
- UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64EncodeUrl(dp)));
+ const TString dp = "ADP GmbH\nAnalyse Design & Programmierung\nGesellschaft mit beschränkter Haftung";
+ UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64Encode(dp)));
+ UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64EncodeUrl(dp)));
}
}
diff --git a/library/cpp/string_utils/base64/base64_ut.cpp b/library/cpp/string_utils/base64/base64_ut.cpp
index bcc1e65879..4ba3cc6eb6 100644
--- a/library/cpp/string_utils/base64/base64_ut.cpp
+++ b/library/cpp/string_utils/base64/base64_ut.cpp
@@ -94,8 +94,8 @@ namespace NB64Etalon {
MAX_IMPL
};
- using TEncodeF = void (*)(const TStringBuf&, TString&);
- using TDecodeF = void (*)(const TStringBuf&, TString&);
+ using TEncodeF = void (*)(const TStringBuf&, TString&);
+ using TDecodeF = void (*)(const TStringBuf&, TString&);
struct TImpl {
TEncodeF Encode = nullptr;
@@ -163,8 +163,8 @@ void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64E
}
}
-static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) {
- TString a, b;
+static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) {
+ TString a, b;
Base64Encode(plain, a);
UNIT_ASSERT_VALUES_EQUAL(a, encoded);
@@ -179,8 +179,8 @@ static void TestEncodeDecodeIntoString(const TString& plain, const TString& enco
UNIT_ASSERT_VALUES_EQUAL(b, plain);
}
-static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) {
- TString a, b;
+static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) {
+ TString a, b;
Base64Encode(plain, a);
UNIT_ASSERT_VALUES_EQUAL(a, encoded);
@@ -205,11 +205,11 @@ Y_UNIT_TEST_SUITE(TBase64) {
Y_UNIT_TEST(TestIntoString) {
{
- TString str;
+ TString str;
for (size_t i = 0; i < 256; ++i)
str += char(i);
- const TString base64 =
+ const TString base64 =
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJy"
"gpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9Q"
"UVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eH"
@@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(TBase64) {
"oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIyc"
"rLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy"
"8/T19vf4+fr7/P3+/w==";
- const TString base64Url =
+ const TString base64Url =
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJy"
"gpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9Q"
"UVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eH"
@@ -231,10 +231,10 @@ Y_UNIT_TEST_SUITE(TBase64) {
}
{
- const TString str = "http://yandex.ru:1234/request?param=value&lll=fff#fragment";
+ const TString str = "http://yandex.ru:1234/request?param=value&lll=fff#fragment";
- const TString base64 = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q/cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA==";
- const TString base64Url = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q_cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA,,";
+ const TString base64 = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q/cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA==";
+ const TString base64Url = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q_cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA,,";
TestEncodeDecodeIntoString(str, base64, base64Url);
TestEncodeStrictDecodeIntoString(str, base64, base64Url);
@@ -286,94 +286,94 @@ Y_UNIT_TEST_SUITE(TBase64) {
}
Y_UNIT_TEST(TestDecodeRandom) {
- TString input;
+ TString input;
constexpr size_t testSize = 240000;
for (size_t i = 0; i < testSize; ++i) {
input.push_back(rand() % 256);
}
- TString output;
- TString encoded = Base64Encode(input);
+ TString output;
+ TString encoded = Base64Encode(input);
UNIT_ASSERT_VALUES_EQUAL(Base64Decode(encoded), input);
UNIT_ASSERT_VALUES_EQUAL(Base64StrictDecode(encoded), input);
}
Y_UNIT_TEST(TestAllPossibleOctets) {
const TString x("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7F"sv);
- const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8=";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8=";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestTwoPaddingCharacters) {
const TString x("a");
- const TString xEnc = "YQ==";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "YQ==";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestOnePaddingCharacter) {
const TString x("aa");
- const TString xEnc = "YWE=";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "YWE=";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestNoPaddingCharacters) {
const TString x("aaa");
- const TString xEnc = "YWFh";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "YWFh";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestTrailingZero) {
const TString x("foo\0"sv);
- const TString xEnc = "Zm9vAA==";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "Zm9vAA==";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestTwoTrailingZeroes) {
const TString x("foo\0\0"sv);
- const TString xEnc = "Zm9vAAA=";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "Zm9vAAA=";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestZero) {
const TString x("\0"sv);
- const TString xEnc = "AA==";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "AA==";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestSymbolsAfterZero) {
const TString x("\0a"sv);
- const TString xEnc = "AGE=";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "AGE=";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
Y_UNIT_TEST(TestEmptyString) {
const TString x = "";
- const TString xEnc = "";
- const TString y = Base64Decode(xEnc);
- const TString yEnc = Base64Encode(x);
+ const TString xEnc = "";
+ const TString y = Base64Decode(xEnc);
+ const TString yEnc = Base64Encode(x);
UNIT_ASSERT_VALUES_EQUAL(x, y);
UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc);
}
@@ -382,11 +382,11 @@ Y_UNIT_TEST_SUITE(TBase64) {
constexpr size_t TEST_CASES_COUNT = 1000;
constexpr size_t MAX_DATA_SIZE = 1000;
TFastRng<ui32> prng{42};
- TVector<TString> xs{TEST_CASES_COUNT};
- TString xEnc;
- TString xDec;
- TString yEnc;
- TString yDec;
+ TVector<TString> xs{TEST_CASES_COUNT};
+ TString xEnc;
+ TString xDec;
+ TString yEnc;
+ TString yDec;
for (auto& x : xs) {
const size_t size = prng() % MAX_DATA_SIZE;
@@ -426,8 +426,8 @@ Y_UNIT_TEST_SUITE(TBase64) {
constexpr size_t TEST_CASES_COUNT = 1000;
constexpr size_t MAX_DATA_SIZE = 1000;
TFastRng<ui32> prng{42};
- TString x;
- TVector<char> buf;
+ TString x;
+ TVector<char> buf;
for (size_t i = 0; i < TEST_CASES_COUNT; ++i) {
const size_t size = prng() % MAX_DATA_SIZE;
x.clear();
diff --git a/library/cpp/string_utils/base64/bench/main.cpp b/library/cpp/string_utils/base64/bench/main.cpp
index 10e09bc1c7..2b371cd3f1 100644
--- a/library/cpp/string_utils/base64/bench/main.cpp
+++ b/library/cpp/string_utils/base64/bench/main.cpp
@@ -4,7 +4,7 @@
#include <util/generic/buffer.h>
#include <util/generic/singleton.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/generic/xrange.h>
#include <util/generic/yexception.h>
@@ -12,9 +12,9 @@
#include <array>
-static TString GenerateRandomData(const size_t minSize, const size_t maxSize) {
+static TString GenerateRandomData(const size_t minSize, const size_t maxSize) {
Y_ENSURE(minSize <= maxSize, "wow");
- TString r;
+ TString r;
for (size_t i = 0; i < minSize; ++i) {
r.push_back(RandomNumber<char>());
}
@@ -32,8 +32,8 @@ static TString GenerateRandomData(const size_t minSize, const size_t maxSize) {
}
template <size_t N>
-static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) {
- std::array<TString, N> r;
+static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) {
+ std::array<TString, N> r;
for (size_t i = 0; i < N; ++i) {
r[i] = GenerateRandomData(minSize, maxSize);
}
@@ -42,8 +42,8 @@ static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, con
}
template <size_t N>
-static std::array<TString, N> Encode(const std::array<TString, N>& d) {
- std::array<TString, N> r;
+static std::array<TString, N> Encode(const std::array<TString, N>& d) {
+ std::array<TString, N> r;
for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) {
r[i] = Base64Encode(d[i]);
}
@@ -67,8 +67,8 @@ namespace {
}
static constexpr size_t Size = N;
- const std::array<TString, N> Data;
- const std::array<TString, N> DataEncoded;
+ const std::array<TString, N> Data;
+ const std::array<TString, N> DataEncoded;
std::array<TBuffer, N> PlaceToEncode;
std::array<TBuffer, N> PlaceToDecode;
};
diff --git a/library/cpp/string_utils/base64/ut/ya.make b/library/cpp/string_utils/base64/ut/ya.make
index 9b61241f0e..ec02357f0a 100644
--- a/library/cpp/string_utils/base64/ut/ya.make
+++ b/library/cpp/string_utils/base64/ut/ya.make
@@ -7,7 +7,7 @@ UNITTEST_FOR(library/cpp/string_utils/base64)
SRCS(
base64_ut.cpp
- base64_decode_uneven_ut.cpp
+ base64_decode_uneven_ut.cpp
)
PEERDIR(