ClickHouse/src/Common/tests/gtest_wide_integer.cpp

25 lines
861 B
C++
Raw Normal View History

2021-05-05 20:56:44 +00:00
#include <gtest/gtest.h>
#include <common/extended_types.h>
#include <IO/WriteHelpers.h>
using namespace DB;
GTEST_TEST(WideInteger, Tests)
{
ASSERT_EQ(toString(UInt128(12345678901234567890ULL)), "12345678901234567890");
ASSERT_EQ(toString(UInt256(12345678901234567890ULL)), "12345678901234567890");
ASSERT_EQ(toString(Int128(-1234567890123456789LL)), "-1234567890123456789");
ASSERT_EQ(toString(Int256(-1234567890123456789LL)), "-1234567890123456789");
ASSERT_EQ(UInt64(UInt128(12345678901234567890ULL)), 12345678901234567890ULL);
ASSERT_EQ(UInt64(UInt256(12345678901234567890ULL)), 12345678901234567890ULL);
ASSERT_EQ(__uint128_t(UInt128(12345678901234567890ULL)), 12345678901234567890ULL);
ASSERT_EQ(__uint128_t(UInt256(12345678901234567890ULL)), 12345678901234567890ULL);
ASSERT_EQ(toString(Int256(-1)), "-1");
}