feat add spdlog
Some checks failed
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Failing after 29s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Failing after 16s
sm-rpc / build (Debug, host.gcc) (push) Failing after 11s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Failing after 12s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Failing after 11s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Failing after 11s
sm-rpc / build (Release, host.gcc) (push) Failing after 12s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Failing after 16s
Some checks failed
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Failing after 29s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Failing after 16s
sm-rpc / build (Debug, host.gcc) (push) Failing after 11s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Failing after 12s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Failing after 11s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Failing after 11s
sm-rpc / build (Release, host.gcc) (push) Failing after 12s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Failing after 16s
This commit is contained in:
10
third_party/prometheus/util/tests/unit/BUILD.bazel
vendored
Normal file
10
third_party/prometheus/util/tests/unit/BUILD.bazel
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
cc_test(
|
||||
name = "unit",
|
||||
srcs = glob(["*.cc"]),
|
||||
copts = ["-Iexternal/googletest/include"],
|
||||
linkstatic = True,
|
||||
deps = [
|
||||
"//util",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
15
third_party/prometheus/util/tests/unit/CMakeLists.txt
vendored
Normal file
15
third_party/prometheus/util/tests/unit/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
add_executable(prometheus_util_test
|
||||
base64_test.cc
|
||||
)
|
||||
|
||||
target_link_libraries(prometheus_util_test
|
||||
PUBLIC
|
||||
${PROJECT_NAME}::util
|
||||
PRIVATE
|
||||
GTest::gmock_main
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME prometheus_util_test
|
||||
COMMAND prometheus_util_test
|
||||
)
|
78
third_party/prometheus/util/tests/unit/base64_test.cc
vendored
Normal file
78
third_party/prometheus/util/tests/unit/base64_test.cc
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "prometheus/detail/base64.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace prometheus {
|
||||
namespace {
|
||||
|
||||
struct TestVector {
|
||||
const std::string decoded;
|
||||
const std::string encoded;
|
||||
};
|
||||
|
||||
const TestVector testVector[] = {
|
||||
// RFC 3548 examples
|
||||
{"\x14\xfb\x9c\x03\xd9\x7e", "FPucA9l+"},
|
||||
{"\x14\xfb\x9c\x03\xd9", "FPucA9k="},
|
||||
{"\x14\xfb\x9c\x03", "FPucAw=="},
|
||||
|
||||
// RFC 4648 examples
|
||||
{"", ""},
|
||||
{"f", "Zg=="},
|
||||
{"fo", "Zm8="},
|
||||
{"foo", "Zm9v"},
|
||||
{"foob", "Zm9vYg=="},
|
||||
{"fooba", "Zm9vYmE="},
|
||||
{"foobar", "Zm9vYmFy"},
|
||||
|
||||
// Wikipedia examples
|
||||
{"sure.", "c3VyZS4="},
|
||||
{"sure", "c3VyZQ=="},
|
||||
{"sur", "c3Vy"},
|
||||
{"su", "c3U="},
|
||||
{"leasure.", "bGVhc3VyZS4="},
|
||||
{"easure.", "ZWFzdXJlLg=="},
|
||||
{"asure.", "YXN1cmUu"},
|
||||
{"sure.", "c3VyZS4="},
|
||||
};
|
||||
|
||||
using namespace testing;
|
||||
|
||||
TEST(Base64Test, encodeTest) {
|
||||
for (const auto& test_case : testVector) {
|
||||
std::string encoded = detail::base64_encode(test_case.decoded);
|
||||
EXPECT_EQ(test_case.encoded, encoded);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Base64Test, encodeUrlTest) {
|
||||
const char unicodeText[] =
|
||||
"\xce\xa0\xcf\x81\xce\xbf\xce\xbc\xce\xb7\xce\xb8\xce\xb5\xcf\x8d\xcf"
|
||||
"\x82"; // Προμηθεύς
|
||||
std::string encoded = detail::base64url_encode(unicodeText);
|
||||
EXPECT_EQ("zqDPgc6_zrzOt864zrXPjc-C", encoded);
|
||||
}
|
||||
|
||||
TEST(Base64Test, decodeTest) {
|
||||
for (const auto& test_case : testVector) {
|
||||
std::string decoded = detail::base64_decode(test_case.encoded);
|
||||
EXPECT_EQ(test_case.decoded, decoded);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Base64Test, rejectInvalidSymbols) {
|
||||
EXPECT_ANY_THROW(detail::base64_decode("...."));
|
||||
}
|
||||
|
||||
TEST(Base64Test, rejectInvalidInputSize) {
|
||||
EXPECT_ANY_THROW(detail::base64_decode("ABC"));
|
||||
}
|
||||
|
||||
TEST(Base64Test, rejectInvalidPadding) {
|
||||
EXPECT_ANY_THROW(detail::base64_decode("A==="));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace prometheus
|
Reference in New Issue
Block a user