12 //#include "ntp_config.h"
14 //#include "ntp_scanner.h"
15 //#include "ntp_parser.h"
17 #include "ntp_scanner.c"
18 /* ntp_keyword.h declares finite state machine and token text */
19 //#include "ntp_keyword.h"
21 void test_keywordIncorrectToken(void);
22 void test_keywordServerToken(void);
23 void test_DropUninitializedStack(void);
24 void test_IncorrectlyInitializeLexStack(void);
25 void test_InitializeLexStack(void);
28 void test_keywordIncorrectToken(void){
29 char * temp = keyword(999);
30 //printf("%s\n",temp);
31 TEST_ASSERT_EQUAL_STRING("(keyword not found)",temp);
34 void test_keywordServerToken(void){
35 char * temp = keyword(401);
36 //printf("%s",temp); //143 or 401 ?
37 TEST_ASSERT_EQUAL_STRING("server",temp);
40 void test_DropUninitializedStack(void){
44 void test_IncorrectlyInitializeLexStack(void){
46 TEST_ASSERT_FALSE(lex_init_stack(NULL,NULL));
50 void test_InitializeLexStack(void){
52 //Some sort of server is required for this to work.
53 sockaddr_u * remote_addr;
54 char origin[128] ={ "" } ;
55 strcat(origin,"127.0.0.1");
56 //snprintf(origin, sizeof(origin), "remote config from %s", stoa(remote_addr));
57 TEST_ASSERT_TRUE(lex_init_stack(origin,NULL)); //path, mode -> NULL is ok!
61 void test_PopEmptyStack(void){
62 int temp = lex_pop_file();
64 TEST_ASSERT_FALSE(temp);
69 void test_IsInteger(void){ //boolean
70 int temp = is_integer("123");
71 TEST_ASSERT_TRUE(temp);
72 temp = is_integer("-999");
73 TEST_ASSERT_TRUE(temp);
74 temp = is_integer("0"); //what about -0?
75 TEST_ASSERT_TRUE(temp);
76 temp = is_integer("16.5");
77 TEST_ASSERT_FALSE(temp);
78 temp = is_integer("12ab");
79 TEST_ASSERT_FALSE(temp);
80 temp = is_integer("2147483647");
81 TEST_ASSERT_TRUE(temp);
82 temp = is_integer("2347483647"); //too big for signed int
83 TEST_ASSERT_FALSE(temp);
87 void test_IsUint(void){
89 temp = is_u_int("-123");
90 TEST_ASSERT_FALSE(temp);
92 TEST_ASSERT_TRUE(temp); //-0 fails btw
93 temp = is_u_int("2347483647"); //fits into u_int
94 TEST_ASSERT_TRUE(temp);
95 temp = is_u_int("112347483647"); //too big even for uint
96 TEST_ASSERT_TRUE(temp);
99 void test_IsDouble(void){
101 temp = is_double("0");
102 TEST_ASSERT_TRUE(temp);
103 temp = is_double("123");
104 TEST_ASSERT_TRUE(temp);
105 temp = is_double("123.45"); //DOESN'T WORK WITH 123,45, not sure if intented?
106 TEST_ASSERT_TRUE(temp);
107 temp = is_double("-123.45"); //DOESN'T WORK WITH 123,45, not sure if intented?
108 TEST_ASSERT_TRUE(temp);
111 void test_SpecialSymbols(void){
113 temp = is_special('a');
114 TEST_ASSERT_FALSE(temp);
115 temp = is_special('?');
116 TEST_ASSERT_FALSE(temp);
122 if(old_config_style){
124 TEST_ASSERT_TRUE(temp);
128 TEST_ASSERT_TRUE(temp);
131 TEST_ASSERT_FALSE(temp);
133 TEST_ASSERT_FALSE(temp);