summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/g_atouint.cpp
blob: ba261dbb10aca68b956d2d9ae0f112e03daffd10 (plain)
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 "g_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));
}
OpenPOWER on IntegriCloud