Implement a fallback uint128_t

This commit is contained in:
Victor Zverovich
2022-02-17 07:30:35 -08:00
parent 6a13464059
commit ce93a66dfb
3 changed files with 59 additions and 3 deletions

View File

@@ -33,6 +33,33 @@ using testing::Return;
# error core-test includes format.h
#endif
TEST(uint128_test, ctor) {
using fmt::detail::uint128_t;
auto n = uint128_t();
EXPECT_EQ(n, 0);
n = uint128_t(42);
EXPECT_EQ(n, 42);
EXPECT_EQ(static_cast<uint64_t>(n), 42);
}
TEST(uint128_test, shift) {
auto n = fmt::detail::uint128_t(42);
n = n << 64;
EXPECT_EQ(static_cast<uint64_t>(n), 0);
n = n >> 64;
EXPECT_EQ(static_cast<uint64_t>(n), 42);
n = n << 62;
EXPECT_EQ(static_cast<uint64_t>(n >> 64), 0xa);
EXPECT_EQ(static_cast<uint64_t>(n), 0x8000000000000000);
n = n >> 62;
EXPECT_EQ(static_cast<uint64_t>(n), 42);
}
TEST(uint128_test, minus) {
auto n = fmt::detail::uint128_t(42);
EXPECT_EQ(n - 2, 40);
}
TEST(string_view_test, value_type) {
static_assert(std::is_same<string_view::value_type, char>::value, "");
}