blob: c20821a9b5e8725f244d4df9a5e535384bab6a4b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "g_libntptest.h"
class hextointTest : public libntptest {
};
TEST_F(hextointTest, SingleDigit) {
const char *str = "a"; // 10 decimal
u_long actual;
ASSERT_TRUE(hextoint(str, &actual));
EXPECT_EQ(10, actual);
}
TEST_F(hextointTest, MultipleDigits) {
const char *str = "8F3"; // 2291 decimal
u_long actual;
ASSERT_TRUE(hextoint(str, &actual));
EXPECT_EQ(2291, actual);
}
TEST_F(hextointTest, MaxUnsigned) {
const char *str = "ffffffff"; // 4294967295 decimal
u_long actual;
ASSERT_TRUE(hextoint(str, &actual));
EXPECT_EQ(4294967295UL, actual);
}
TEST_F(hextointTest, Overflow) {
const char *str = "100000000"; // Overflow by 1
u_long actual;
ASSERT_FALSE(hextoint(str, &actual));
}
TEST_F(hextointTest, IllegalChar) {
const char *str = "5gb"; // Illegal character g
u_long actual;
ASSERT_FALSE(hextoint(str, &actual));
}
|