1 #include "config.h" 2 3 #include "ntp_stdlib.h" 4 #include "ntp_calendar.h" 5 #include "unity.h" 6 7 void test_RegularPositive(void); 8 void test_RegularNegative(void); 9 void test_PositiveOverflowBoundary(void); 10 void test_NegativeOverflowBoundary(void); 11 void test_PositiveOverflowBig(void); 12 void test_IllegalCharacter(void); 13 14 15 16 void test_RegularPositive(void) { 17 const char *str = "17"; 18 long val; 19 20 TEST_ASSERT_TRUE(atoint(str, &val)); 21 TEST_ASSERT_EQUAL(17, val); 22 } 23 24 void test_RegularNegative(void) { 25 const char *str = "-20"; 26 long val; 27 28 TEST_ASSERT_TRUE(atoint(str, &val)); 29 TEST_ASSERT_EQUAL(-20, val); 30 } 31 32 void test_PositiveOverflowBoundary(void) { 33 const char *str = "2147483648"; 34 long val; 35 36 TEST_ASSERT_FALSE(atoint(str, &val)); 37 } 38 39 void test_NegativeOverflowBoundary(void) { 40 const char *str = "-2147483649"; 41 long val; 42 43 TEST_ASSERT_FALSE(atoint(str, &val)); 44 } 45 46 void test_PositiveOverflowBig(void) { 47 const char *str = "2300000000"; 48 long val; 49 50 TEST_ASSERT_FALSE(atoint(str, &val)); 51 } 52 53 void test_IllegalCharacter(void) { 54 const char *str = "4500l"; 55 long val; 56 57 TEST_ASSERT_FALSE(atoint(str, &val)); 58 } 59 60 61