aboutsummaryrefslogtreecommitdiff
path: root/tests/libntp/atouint.cpp
blob: cc8cc394b840a8ff6258b6e634b34977c2b107cd (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
#include "libntptest.h"

class atouintTest : public libntptest {
};

TEST_F(atouintTest, RegularPositive) {
	const char *str = "305";
	u_long actual;

	ASSERT_TRUE(atouint(str, &actual));
	EXPECT_EQ(305, actual);
}

TEST_F(atouintTest, PositiveOverflowBoundary) {
	const char *str = "4294967296";
	u_long actual;

	ASSERT_FALSE(atouint(str, &actual));
}

TEST_F(atouintTest, PositiveOverflowBig) {
	const char *str = "8000000000";
	u_long actual;

	ASSERT_FALSE(atouint(str, &actual));
}

TEST_F(atouintTest, Negative) {
	const char *str = "-1";
	u_long actual;

	ASSERT_FALSE(atouint(str, &actual));
}

TEST_F(atouintTest, IllegalChar) {
	const char *str = "50c3";
	u_long actual;

	ASSERT_FALSE(atouint(str, &actual));
}