mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-03 15:41:53 +01:00
Implement a fallback uint128_t
This commit is contained in:
@@ -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, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user