1/*	$NetBSD: atouint.c,v 1.2 2020/05/25 20:47:36 christos Exp $	*/
2
3#include "config.h"
4
5#include "ntp_stdlib.h"
6#include "ntp_calendar.h"
7#include "ntp_fp.h"
8
9#include "unity.h"
10
11void test_RegularPositive(void);
12void test_PositiveOverflowBoundary(void);
13void test_PositiveOverflowBig(void);
14void test_Negative(void);
15void test_IllegalChar(void);
16
17
18
19void test_RegularPositive(void) {
20	const char *str = "305";
21	u_long actual;
22
23	TEST_ASSERT_TRUE(atouint(str, &actual));
24	TEST_ASSERT_EQUAL(305, actual);
25}
26
27void test_PositiveOverflowBoundary(void) {
28	const char *str = "4294967296";
29	u_long actual;
30
31	TEST_ASSERT_FALSE(atouint(str, &actual));
32}
33
34void test_PositiveOverflowBig(void) {
35	const char *str = "8000000000";
36	u_long actual;
37
38	TEST_ASSERT_FALSE(atouint(str, &actual));
39}
40
41void test_Negative(void) {
42	const char *str = "-1";
43	u_long actual;
44
45	TEST_ASSERT_FALSE(atouint(str, &actual));
46}
47
48void test_IllegalChar(void) {
49	const char *str = "50c3";
50	u_long actual;
51
52	TEST_ASSERT_FALSE(atouint(str, &actual));
53}
54