updated build system
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...

This commit is contained in:
2024-08-03 12:15:08 -05:00
parent 7a1fb4a790
commit 035f830b71
34 changed files with 32 additions and 27 deletions

View File

@ -0,0 +1,67 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "gtest/gtest.h"
#include "utils/common.hpp"
namespace repertory {
TEST(utils_common, version_equal) {
EXPECT_EQ(0, utils::compare_version_strings("1.0", "1.0"));
EXPECT_EQ(0, utils::compare_version_strings("1.0.0", "1.0"));
EXPECT_EQ(0, utils::compare_version_strings("1.0.0.0", "1.0"));
EXPECT_EQ(0, utils::compare_version_strings("1.0.0.0", "1.0.0"));
}
TEST(utils_common, version_greater) {
EXPECT_EQ(1, utils::compare_version_strings("1.0.1", "1.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1", "1.0.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1", "1.0.0.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1.0", "1.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1.0", "1.0.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1.0", "1.0.0.0"));
EXPECT_EQ(1, utils::compare_version_strings("1.0", "0.9.9"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1", "0.9.9"));
EXPECT_EQ(1, utils::compare_version_strings("1.0.1.0", "0.9.9"));
}
TEST(utils_common, version_less) {
EXPECT_EQ(-1, utils::compare_version_strings("0.9.9", "1.0"));
EXPECT_EQ(-1, utils::compare_version_strings("0.9.9", "1.0.1"));
EXPECT_EQ(-1, utils::compare_version_strings("0.9.9", "1.0.1.0"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0", "1.0.1"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0", "1.0.1.0"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0.0", "1.0.1"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0.0", "1.0.1.0"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0.0.0", "1.0.1"));
EXPECT_EQ(-1, utils::compare_version_strings("1.0.0.0", "1.0.1.0"));
}
#if defined(PROJECT_ENABLE_STDUUID)
TEST(utils_common, create_uuid_string) {
const auto uuid1 = utils::create_uuid_string();
const auto uuid2 = utils::create_uuid_string();
ASSERT_EQ(36U, uuid1.size());
ASSERT_EQ(36U, uuid2.size());
ASSERT_STRNE(uuid1.c_str(), uuid2.c_str());
}
#endif // defined(PROJECT_ENABLE_STDUUID)
} // namespace repertory

View File

@ -0,0 +1,139 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
#include "gtest/gtest.h"
#include "utils/collection.hpp"
#include "utils/encryption.hpp"
namespace repertory {
static const std::string buffer = "cow moose dog chicken";
static const std::string token = "moose";
static void test_encrypted_result(const data_buffer &result) {
EXPECT_EQ(buffer.size() + utils::encryption::encryption_header_size,
result.size());
std::string data;
EXPECT_TRUE(utils::encryption::decrypt_data(token, result, data));
EXPECT_EQ(buffer.size(), data.size());
EXPECT_STREQ(buffer.c_str(), data.c_str());
}
TEST(utils_encryption, generate_key) {
const auto key = utils::encryption::generate_key(token);
const auto str = utils::collection::to_hex_string(key);
EXPECT_STREQ(
"182072537ada59e4d6b18034a80302ebae935f66adbdf0f271d3d36309c2d481",
str.c_str());
}
TEST(utils_encryption, encrypt_data_buffer) {
data_buffer result;
utils::encryption::encrypt_data(token, buffer, result);
test_encrypted_result(result);
}
TEST(utils_encryption, encrypt_data_buffer_with_key) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(key, buffer, result);
test_encrypted_result(result);
}
TEST(utils_encryption, encrypt_data_pointer) {
data_buffer result;
utils::encryption::encrypt_data(
token, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
test_encrypted_result(result);
}
TEST(utils_encryption, encrypt_data_pointer_with_key) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(
key, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
test_encrypted_result(result);
}
TEST(utils_encryption, decrypt_data_pointer) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(
key, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
std::string data;
EXPECT_TRUE(utils::encryption::decrypt_data(token, result.data(),
result.size(), data));
EXPECT_EQ(buffer.size(), data.size());
EXPECT_STREQ(buffer.c_str(), data.c_str());
}
TEST(utils_encryption, decrypt_data_buffer_with_key) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(
key, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
std::string data;
EXPECT_TRUE(utils::encryption::decrypt_data(key, result, data));
EXPECT_EQ(buffer.size(), data.size());
EXPECT_STREQ(buffer.c_str(), data.c_str());
}
TEST(utils_encryption, decrypt_data_pointer_with_key) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(
key, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
std::string data;
EXPECT_TRUE(
utils::encryption::decrypt_data(key, result.data(), result.size(), data));
EXPECT_EQ(buffer.size(), data.size());
EXPECT_STREQ(buffer.c_str(), data.c_str());
}
TEST(utils_encryption, decryption_failure) {
const auto key = utils::encryption::generate_key(token);
data_buffer result;
utils::encryption::encrypt_data(
key, reinterpret_cast<const unsigned char *>(buffer.data()),
buffer.size(), result);
result[0U] = 0U;
result[1U] = 1U;
result[2U] = 2U;
std::string data;
EXPECT_FALSE(utils::encryption::decrypt_data(key, result, data));
}
} // namespace repertory
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)

View File

@ -0,0 +1,264 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "gtest/gtest.h"
#include "utils/common.hpp"
#include "utils/path.hpp"
#include "utils/string.hpp"
namespace repertory {
TEST(utils_path, constants) {
EXPECT_EQ(std::string_view{"\\"}, utils::path::backslash);
EXPECT_EQ(std::wstring_view{L"\\"}, utils::path::backslash_w);
EXPECT_EQ(std::string_view{"."}, utils::path::dot);
EXPECT_EQ(std::wstring_view{L"."}, utils::path::dot_w);
EXPECT_EQ(std::string_view{"./"}, utils::path::dot_slash);
EXPECT_EQ(std::wstring_view{L"./"}, utils::path::dot_slash_w);
EXPECT_EQ(std::string_view{"/"}, utils::path::slash);
EXPECT_EQ(std::wstring_view{L"/"}, utils::path::slash_w);
}
TEST(utils_path, directory_seperator) {
#if defined(_WIN32)
EXPECT_EQ(utils::path::backslash, utils::path::directory_seperator);
EXPECT_EQ(utils::path::backslash_w, utils::path::directory_seperator_w);
EXPECT_EQ(utils::path::slash, utils::path::not_directory_seperator);
EXPECT_EQ(utils::path::slash_w, utils::path::not_directory_seperator_w);
#else // !defined(_WIN32)
EXPECT_EQ(utils::path::slash, utils::path::directory_seperator);
EXPECT_EQ(utils::path::slash_w, utils::path::directory_seperator_w);
EXPECT_EQ(utils::path::backslash, utils::path::not_directory_seperator);
EXPECT_EQ(utils::path::backslash_w, utils::path::not_directory_seperator_w);
#endif // defined(_WIN32)
}
TEST(utils_path, get_directory_seperator) {
#if defined(_WIN32)
EXPECT_EQ(utils::path::backslash,
utils::path::get_directory_seperator<char>());
EXPECT_EQ(utils::path::backslash_w,
utils::path::get_directory_seperator<wchar_t>());
EXPECT_EQ(utils::path::slash,
utils::path::get_not_directory_seperator<char>());
EXPECT_EQ(utils::path::slash_w,
utils::path::get_not_directory_seperator<wchar_t>());
#else // !defined(_WIN32)
EXPECT_EQ(utils::path::slash, utils::path::get_directory_seperator<char>());
EXPECT_EQ(utils::path::slash_w,
utils::path::get_directory_seperator<wchar_t>());
EXPECT_EQ(utils::path::backslash,
utils::path::get_not_directory_seperator<char>());
EXPECT_EQ(utils::path::backslash_w,
utils::path::get_not_directory_seperator<wchar_t>());
#endif // defined(_WIN32)
}
TEST(utils_path, get_backslash) {
EXPECT_EQ(utils::path::backslash, utils::path::get_backslash<char>());
EXPECT_EQ(utils::path::backslash_w, utils::path::get_backslash<wchar_t>());
}
TEST(utils_path, get_dot) {
EXPECT_EQ(utils::path::dot, utils::path::get_dot<char>());
EXPECT_EQ(utils::path::dot_w, utils::path::get_dot<wchar_t>());
}
TEST(utils_path, get_dot_slash) {
EXPECT_EQ(utils::path::dot_slash, utils::path::get_dot_slash<char>());
EXPECT_EQ(utils::path::dot_slash_w, utils::path::get_dot_slash<wchar_t>());
}
TEST(utils_path, get_slash) {
EXPECT_EQ(utils::path::slash, utils::path::get_slash<char>());
EXPECT_EQ(utils::path::slash_w, utils::path::get_slash<wchar_t>());
}
TEST(utils_path, combine) {
auto s = utils::path::combine(R"(\test\path)", {});
#if defined(_WIN32)
EXPECT_STREQ(R"(\test\path)", s.c_str());
#else
EXPECT_STREQ("/test/path", s.c_str());
#endif
s = utils::path::combine(R"(\test)", {R"(\path)"});
#if defined(_WIN32)
EXPECT_STREQ(R"(\test\path)", s.c_str());
#else
EXPECT_STREQ("/test/path", s.c_str());
#endif
s = utils::path::combine(R"(\test)", {R"(\path)", R"(\again\)"});
#if defined(_WIN32)
EXPECT_STREQ(R"(\test\path\again)", s.c_str());
#else
EXPECT_STREQ("/test/path/again", s.c_str());
#endif
}
TEST(utils_path, format_path) {
std::string path{"./"};
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ(".", path.c_str());
path = "~/.test";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("~/.test", path.c_str());
path = "\\";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\\\";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\\\\\";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "/";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "//";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "///";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "////";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
}
TEST(utils_path, create_api_path) {
auto s = utils::path::create_api_path("");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path(R"(\)");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path("/");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path(".");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path("./");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path(R"(\\)");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path("//");
EXPECT_STREQ("/", s.c_str());
s = utils::path::create_api_path("/cow///moose/////dog/chicken");
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
s = utils::path::create_api_path("\\cow\\\\\\moose\\\\\\\\dog\\chicken/");
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
s = utils::path::create_api_path("/cow\\\\/moose\\\\/\\dog\\chicken\\");
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
}
TEST(utils_path, finalize) {
auto s = utils::path::finalize("");
EXPECT_STREQ("", s.c_str());
s = utils::path::finalize(R"(\)");
#if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
s = utils::path::finalize("/");
#if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
s = utils::path::finalize(R"(\\)");
#if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
s = utils::path::finalize("//");
#if defined(_WIN32)
EXPECT_STREQ(R"(\)", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
s = utils::path::finalize("/cow///moose/////dog/chicken");
#if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif
s = utils::path::finalize("\\cow\\\\\\moose\\\\\\\\dog\\chicken/");
#if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif
s = utils::path::finalize("/cow\\\\/moose\\\\/\\dog\\chicken\\");
#if defined(_WIN32)
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
#else
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif
}
TEST(utils_path, absolute) {
auto dir = utils::path::absolute(std::filesystem::current_path().string());
auto path = utils::path::absolute(".");
EXPECT_STREQ(dir.c_str(), path.c_str());
path = utils::path::absolute("./");
EXPECT_STREQ(dir.c_str(), path.c_str());
auto home = utils::path::absolute(utils::get_environment_variable("HOME"));
path = utils::path::absolute("~");
EXPECT_STREQ(home.c_str(), path.c_str());
// path = utils::path::absolute("~/.local");
}
} // namespace repertory

View File

@ -0,0 +1,139 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "gtest/gtest.h"
#include "utils/string.hpp"
namespace repertory {
TEST(utils_string, begins_with) {
std::string str{"moose"};
EXPECT_TRUE(utils::string::begins_with(str, "m"));
EXPECT_TRUE(utils::string::begins_with(str, "mo"));
EXPECT_TRUE(utils::string::begins_with(str, "moo"));
EXPECT_TRUE(utils::string::begins_with(str, "moos"));
EXPECT_TRUE(utils::string::begins_with(str, "moose"));
EXPECT_FALSE(utils::string::begins_with(str, "a"));
EXPECT_FALSE(utils::string::begins_with(str, "ma"));
EXPECT_FALSE(utils::string::begins_with(str, "moose1"));
std::wstring str_w{L"moose"};
EXPECT_TRUE(utils::string::begins_with(str_w, L"m"));
EXPECT_TRUE(utils::string::begins_with(str_w, L"mo"));
EXPECT_TRUE(utils::string::begins_with(str_w, L"moo"));
EXPECT_TRUE(utils::string::begins_with(str_w, L"moos"));
EXPECT_TRUE(utils::string::begins_with(str_w, L"moose"));
EXPECT_FALSE(utils::string::begins_with(str_w, L"a"));
EXPECT_FALSE(utils::string::begins_with(str_w, L"ma"));
EXPECT_FALSE(utils::string::begins_with(str_w, L"moose1"));
}
TEST(utils_string, contains) {
std::string str{R"(\\)"};
EXPECT_TRUE(utils::string::contains(str, "\\"));
EXPECT_FALSE(utils::string::contains(str, "/"));
std::wstring str_w{LR"(\\)"};
EXPECT_TRUE(utils::string::contains(str_w, L"\\"));
EXPECT_FALSE(utils::string::contains(str_w, L"/"));
}
TEST(utils_string, replace) {
std::string str{"moose"};
utils::string::replace(str, 'o', '0');
EXPECT_STREQ("m00se", str.c_str());
std::wstring str_w{L"moose"};
utils::string::replace(str_w, 'o', '0');
EXPECT_STREQ(L"m00se", str_w.c_str());
std::string str2{"\\\\\\"};
utils::string::replace(str2, '\\', '/');
EXPECT_STREQ("///", str2.c_str());
std::wstring str_w2{L"\\\\\\"};
utils::string::replace(str_w2, '\\', '/');
EXPECT_STREQ(L"///", str_w2.c_str());
std::string str3{"///"};
utils::string::replace(str3, '/', '\\');
EXPECT_STREQ("\\\\\\", str3.c_str());
std::wstring str_w3{L"///"};
utils::string::replace(str_w3, '/', '\\');
EXPECT_STREQ(L"\\\\\\", str_w3.c_str());
str.clear();
utils::string::replace(str, '/', '\\');
EXPECT_STREQ("", str.c_str());
str_w.clear();
utils::string::replace(str_w, '/', '\\');
EXPECT_STREQ(L"", str_w.c_str());
}
TEST(utils_string, replace_string) {
std::string str{"moose"};
utils::string::replace(str, "o", "0");
EXPECT_STREQ("m00se", str.c_str());
std::wstring str_w{L"moose"};
utils::string::replace(str_w, L"o", L"0");
EXPECT_STREQ(L"m00se", str_w.c_str());
}
TEST(utils_string, is_numeric) {
EXPECT_TRUE(utils::string::is_numeric("100"));
EXPECT_TRUE(utils::string::is_numeric("+100"));
EXPECT_TRUE(utils::string::is_numeric("-100"));
EXPECT_TRUE(utils::string::is_numeric("100.00"));
EXPECT_TRUE(utils::string::is_numeric("+100.00"));
EXPECT_TRUE(utils::string::is_numeric("-100.00"));
EXPECT_FALSE(utils::string::is_numeric("1.00.00"));
EXPECT_FALSE(utils::string::is_numeric("+1.00.00"));
EXPECT_FALSE(utils::string::is_numeric("-1.00.00"));
EXPECT_FALSE(utils::string::is_numeric("a1"));
EXPECT_FALSE(utils::string::is_numeric("1a"));
EXPECT_FALSE(utils::string::is_numeric("+"));
EXPECT_FALSE(utils::string::is_numeric("-"));
EXPECT_FALSE(utils::string::is_numeric(""));
}
TEST(utils_string, to_bool) {
EXPECT_TRUE(utils::string::to_bool("1"));
EXPECT_TRUE(utils::string::to_bool("-1"));
EXPECT_TRUE(utils::string::to_bool("0.1"));
EXPECT_TRUE(utils::string::to_bool("-0.1"));
EXPECT_TRUE(utils::string::to_bool("00000.1000000"));
EXPECT_TRUE(utils::string::to_bool("true"));
EXPECT_FALSE(utils::string::to_bool("false"));
EXPECT_FALSE(utils::string::to_bool("0"));
EXPECT_FALSE(utils::string::to_bool("00000.00000"));
}
} // namespace repertory