• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 
3 #include <fxdiv.h>
4 
TEST(uint32_t,cases)5 TEST(uint32_t, cases) {
6 	EXPECT_EQ(UINT32_C(0),              fxdiv_mulhi_uint32_t(UINT32_C(0),         UINT32_C(0)));
7 	EXPECT_EQ(UINT32_C(0),              fxdiv_mulhi_uint32_t(UINT32_C(1),         UINT32_C(1)));
8 	EXPECT_EQ(UINT32_C(0),              fxdiv_mulhi_uint32_t(UINT32_C(1),         UINT32_MAX));
9 	EXPECT_EQ(UINT32_C(0),              fxdiv_mulhi_uint32_t(UINT32_MAX,          UINT32_C(1)));
10 	EXPECT_EQ(UINT32_C(1),              fxdiv_mulhi_uint32_t(UINT32_C(65536),     UINT32_C(65536)));
11 	EXPECT_EQ(UINT32_MAX - UINT32_C(1), fxdiv_mulhi_uint32_t(UINT32_MAX,          UINT32_MAX));
12 	EXPECT_EQ(UINT32_C(28389652),       fxdiv_mulhi_uint32_t(UINT32_C(123456789), UINT32_C(987654321)));
13 	EXPECT_EQ(UINT32_C(28389652),       fxdiv_mulhi_uint32_t(UINT32_C(987654321), UINT32_C(123456789)));
14 }
15 
TEST(uint64_t,cases)16 TEST(uint64_t, cases) {
17 	EXPECT_EQ(UINT64_C(0),              fxdiv_mulhi_uint64_t(UINT64_C(0),                 UINT64_C(0)));
18 	EXPECT_EQ(UINT64_C(0),              fxdiv_mulhi_uint64_t(UINT64_C(1),                 UINT64_C(1)));
19 	EXPECT_EQ(UINT64_C(0),              fxdiv_mulhi_uint64_t(UINT64_C(1),                 UINT64_MAX));
20 	EXPECT_EQ(UINT64_C(0),              fxdiv_mulhi_uint64_t(UINT64_MAX,                  UINT64_C(1)));
21 	EXPECT_EQ(UINT64_C(1),              fxdiv_mulhi_uint64_t(UINT64_C(4294967296),        UINT64_C(4294967296)));
22 	EXPECT_EQ(UINT64_MAX - UINT64_C(1), fxdiv_mulhi_uint64_t(UINT64_MAX,                  UINT64_MAX));
23 	EXPECT_EQ(UINT64_C(66099812259603), fxdiv_mulhi_uint64_t(UINT64_C(12345678987654321), UINT64_C(98765432123456789)));
24 	EXPECT_EQ(UINT64_C(66099812259603), fxdiv_mulhi_uint64_t(UINT64_C(98765432123456789), UINT64_C(12345678987654321)));
25 }
26 
TEST(size_t,cases)27 TEST(size_t, cases) {
28 	EXPECT_EQ(0,            fxdiv_mulhi_size_t(0,        0));
29 	EXPECT_EQ(0,            fxdiv_mulhi_size_t(1,        1));
30 	EXPECT_EQ(0,            fxdiv_mulhi_size_t(1,        SIZE_MAX));
31 	EXPECT_EQ(0,            fxdiv_mulhi_size_t(SIZE_MAX, 1));
32 	EXPECT_EQ(SIZE_MAX - 1, fxdiv_mulhi_size_t(SIZE_MAX, SIZE_MAX));
33 }
34