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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "libntptest.h"
class octtointTest : public libntptest {
};
TEST_F(octtointTest, SingleDigit) {
const char* str = "5";
u_long actual;
ASSERT_TRUE(octtoint(str, &actual));
EXPECT_EQ(5, actual);
}
TEST_F(octtointTest, MultipleDigits) {
const char* str = "271";
u_long actual;
ASSERT_TRUE(octtoint(str, &actual));
EXPECT_EQ(185, actual);
}
TEST_F(octtointTest, Zero) {
const char* str = "0";
u_long actual;
ASSERT_TRUE(octtoint(str, &actual));
EXPECT_EQ(0, actual);
}
TEST_F(octtointTest, MaximumUnsigned32bit) {
const char* str = "37777777777";
u_long actual;
ASSERT_TRUE(octtoint(str, &actual));
EXPECT_EQ(4294967295UL, actual);
}
TEST_F(octtointTest, Overflow) {
const char* str = "40000000000";
u_long actual;
ASSERT_FALSE(octtoint(str, &actual));
}
TEST_F(octtointTest, IllegalCharacter) {
const char* str = "5ac2";
u_long actual;
ASSERT_FALSE(octtoint(str, &actual));
}
TEST_F(octtointTest, IllegalDigit) {
const char* str = "5283";
u_long actual;
ASSERT_FALSE(octtoint(str, &actual));
}
|