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