]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/libntp/octtoint.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / ntp / tests / libntp / octtoint.c
1 #include "config.h"
2
3 #include "ntp_stdlib.h"
4
5 #include "unity.h"
6
7 void test_SingleDigit(void) {
8         const char* str = "5";
9         u_long actual;
10
11         TEST_ASSERT_TRUE(octtoint(str, &actual) );
12         TEST_ASSERT_EQUAL(5, actual);
13 }
14
15 void test_MultipleDigits(void){
16         const char* str = "271";
17         u_long actual;
18
19         TEST_ASSERT_TRUE(octtoint(str, &actual) );
20         TEST_ASSERT_EQUAL(185, actual);
21
22 }
23
24 void test_Zero(void){
25         const char* str = "0";
26         u_long actual;
27
28         TEST_ASSERT_TRUE(octtoint(str, &actual) );
29         TEST_ASSERT_EQUAL(0, actual);
30
31 }
32
33 void test_MaximumUnsigned32bit(void){
34         const char* str = "37777777777";
35         u_long actual;
36
37         TEST_ASSERT_TRUE(octtoint(str, &actual) );
38         TEST_ASSERT_EQUAL(4294967295UL, actual);
39
40 }
41
42 void test_Overflow(void){
43         const char* str = "40000000000";
44         u_long actual;
45
46         TEST_ASSERT_FALSE(octtoint(str, &actual) );
47
48 }
49
50 void test_IllegalCharacter(void){
51         const char* str = "5ac2";
52         u_long actual;
53
54         TEST_ASSERT_FALSE(octtoint(str, &actual) );
55
56 }
57
58 void test_IllegalDigit(void){
59         const char* str = "5283";
60         u_long actual;
61
62         TEST_ASSERT_FALSE(octtoint(str, &actual) );
63
64 }