3 #include "ntp_stdlib.h"
4 #include "ntp_calendar.h"
9 void test_SingleDigit(void);
10 void test_MultipleDigits(void);
11 void test_MaxUnsigned(void);
12 void test_Overflow(void);
13 void test_IllegalChar(void);
16 void test_SingleDigit(void) {
17 const char *str = "a"; // 10 decimal
20 TEST_ASSERT_TRUE(hextoint(str, &actual));
21 TEST_ASSERT_EQUAL(10, actual);
24 void test_MultipleDigits(void) {
25 const char *str = "8F3"; // 2291 decimal
28 TEST_ASSERT_TRUE(hextoint(str, &actual));
29 TEST_ASSERT_EQUAL(2291, actual);
32 void test_MaxUnsigned(void) {
33 const char *str = "ffffffff"; // 4294967295 decimal
36 TEST_ASSERT_TRUE(hextoint(str, &actual));
37 TEST_ASSERT_EQUAL(4294967295UL, actual);
40 void test_Overflow(void) {
41 const char *str = "100000000"; // Overflow by 1
44 TEST_ASSERT_FALSE(hextoint(str, &actual));
47 void test_IllegalChar(void) {
48 const char *str = "5gb"; // Illegal character g
51 TEST_ASSERT_FALSE(hextoint(str, &actual));