Merge branch 'main' into curl

This commit is contained in:
MihailRis
2024-11-21 08:58:19 +03:00
149 changed files with 1866 additions and 434 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ TEST(TOML, EncodeDecode) {
std::cout << text << std::endl;
}
try {
auto object = toml::parse("<string>", text);
auto object = toml::parse("[string]", text);
EXPECT_EQ(object["name"].asString(), name);
EXPECT_EQ(object["year"].asInteger(), year);
EXPECT_FLOAT_EQ(object["score"].asNumber(), score);
@@ -86,7 +86,7 @@ inline std::string SRC_EXAMPLE =
TEST(TOML, ExampleCode) {
try {
std::cout << SRC_EXAMPLE << std::endl;
auto object = toml::parse("<string>", SRC_EXAMPLE);
auto object = toml::parse("[string]", SRC_EXAMPLE);
std::cout << object << std::endl;
} catch (const parsing_error& err) {
std::cerr << err.errorLog() << std::endl;
+16
View File
@@ -15,3 +15,19 @@ TEST(stringutil, utf8) {
std::string str2 = util::u32str2str_utf8(u32str);
EXPECT_EQ(str, str2);
}
TEST(stringutil, base64) {
srand(2019);
for (size_t size = 0; size < 30; size++) {
auto bytes = std::make_unique<ubyte[]>(size);
for (int i = 0; i < size; i++) {
bytes[i] = rand();
}
auto base64 = util::base64_encode(bytes.get(), size);
auto decoded = util::base64_decode(base64);
ASSERT_EQ(size, decoded.size());
for (size_t i = 0; i < size; i++) {
ASSERT_EQ(bytes[i], decoded[i]);
}
}
}