Skip to content

Commit 3cb4e5c

Browse files
add test for command types
1 parent bf19bc9 commit 3cb4e5c

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

code/tests/cases/test_parser.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ FOSSIL_TEST_CASE(c_create_palette) {
5151
FOSSIL_TEST_ASSUME(strcmp(palette->description, "Test Description") == 0, "Palette description should be 'Test Description'");
5252
FOSSIL_TEST_ASSUME(palette->commands == NULL, "Palette commands should be NULL");
5353
fossil_io_parser_free(palette);
54+
palette = NULL;
5455
} // end case
5556

5657
FOSSIL_TEST_CASE(c_add_command) {
@@ -96,6 +97,48 @@ FOSSIL_TEST_CASE(c_free_palette) {
9697
// No explicit assumptions here, just ensuring no memory leaks or crashes
9798
} // end case
9899

100+
FOSSIL_TEST_CASE(c_argument_types) {
101+
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
102+
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
103+
104+
// Test BOOL argument
105+
fossil_io_parser_argument_t *bool_arg = fossil_io_parser_add_argument(command, "bool_arg", FOSSIL_IO_PARSER_BOOL, NULL, 0);
106+
FOSSIL_TEST_ASSUME(bool_arg != NULL, "BOOL argument should be added");
107+
FOSSIL_TEST_ASSUME(bool_arg->type == FOSSIL_IO_PARSER_BOOL, "BOOL argument type should be correct");
108+
109+
// Test STRING argument
110+
fossil_io_parser_argument_t *string_arg = fossil_io_parser_add_argument(command, "string_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
111+
FOSSIL_TEST_ASSUME(string_arg != NULL, "STRING argument should be added");
112+
FOSSIL_TEST_ASSUME(string_arg->type == FOSSIL_IO_PARSER_STRING, "STRING argument type should be correct");
113+
114+
// Test INT argument
115+
fossil_io_parser_argument_t *int_arg = fossil_io_parser_add_argument(command, "int_arg", FOSSIL_IO_PARSER_INT, NULL, 0);
116+
FOSSIL_TEST_ASSUME(int_arg != NULL, "INT argument should be added");
117+
FOSSIL_TEST_ASSUME(int_arg->type == FOSSIL_IO_PARSER_INT, "INT argument type should be correct");
118+
119+
// Test FLOAT argument
120+
fossil_io_parser_argument_t *float_arg = fossil_io_parser_add_argument(command, "float_arg", FOSSIL_IO_PARSER_FLOAT, NULL, 0);
121+
FOSSIL_TEST_ASSUME(float_arg != NULL, "FLOAT argument should be added");
122+
FOSSIL_TEST_ASSUME(float_arg->type == FOSSIL_IO_PARSER_FLOAT, "FLOAT argument type should be correct");
123+
124+
// Test DATE argument
125+
fossil_io_parser_argument_t *date_arg = fossil_io_parser_add_argument(command, "date_arg", FOSSIL_IO_PARSER_DATE, NULL, 0);
126+
FOSSIL_TEST_ASSUME(date_arg != NULL, "DATE argument should be added");
127+
FOSSIL_TEST_ASSUME(date_arg->type == FOSSIL_IO_PARSER_DATE, "DATE argument type should be correct");
128+
129+
// Test ARRAY argument
130+
fossil_io_parser_argument_t *array_arg = fossil_io_parser_add_argument(command, "array_arg", FOSSIL_IO_PARSER_ARRAY, NULL, 0);
131+
FOSSIL_TEST_ASSUME(array_arg != NULL, "ARRAY argument should be added");
132+
FOSSIL_TEST_ASSUME(array_arg->type == FOSSIL_IO_PARSER_ARRAY, "ARRAY argument type should be correct");
133+
134+
// Test FEATURE argument
135+
fossil_io_parser_argument_t *feature_arg = fossil_io_parser_add_argument(command, "feature_arg", FOSSIL_IO_PARSER_FEATURE, NULL, 0);
136+
FOSSIL_TEST_ASSUME(feature_arg != NULL, "FEATURE argument should be added");
137+
FOSSIL_TEST_ASSUME(feature_arg->type == FOSSIL_IO_PARSER_FEATURE, "FEATURE argument type should be correct");
138+
139+
fossil_io_parser_free(palette);
140+
} // end case
141+
99142
// * * * * * * * * * * * * * * * * * * * * * * * *
100143
// * Fossil Logic Test Pool
101144
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -105,6 +148,7 @@ FOSSIL_TEST_GROUP(c_parser_test_cases) {
105148
FOSSIL_TEST_ADD(c_parser_suite, c_add_argument);
106149
FOSSIL_TEST_ADD(c_parser_suite, c_parse_command);
107150
FOSSIL_TEST_ADD(c_parser_suite, c_free_palette);
151+
FOSSIL_TEST_ADD(c_parser_suite, c_argument_types);
108152

109153
FOSSIL_TEST_REGISTER(c_parser_suite);
110154
} // end of group

code/tests/cases/test_parser.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,48 @@ FOSSIL_TEST_CASE(cpp_add_argument) {
7878
fossil_io_parser_free(palette);
7979
} // end case
8080

81+
FOSSIL_TEST_CASE(cpp_argument_types) {
82+
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
83+
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
84+
85+
// Test BOOL argument
86+
fossil_io_parser_argument_t *bool_arg = fossil_io_parser_add_argument(command, "bool_arg", FOSSIL_IO_PARSER_BOOL, NULL, 0);
87+
FOSSIL_TEST_ASSUME(bool_arg != NULL, "BOOL argument should be added");
88+
FOSSIL_TEST_ASSUME(bool_arg->type == FOSSIL_IO_PARSER_BOOL, "BOOL argument type should be correct");
89+
90+
// Test STRING argument
91+
fossil_io_parser_argument_t *string_arg = fossil_io_parser_add_argument(command, "string_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
92+
FOSSIL_TEST_ASSUME(string_arg != NULL, "STRING argument should be added");
93+
FOSSIL_TEST_ASSUME(string_arg->type == FOSSIL_IO_PARSER_STRING, "STRING argument type should be correct");
94+
95+
// Test INT argument
96+
fossil_io_parser_argument_t *int_arg = fossil_io_parser_add_argument(command, "int_arg", FOSSIL_IO_PARSER_INT, NULL, 0);
97+
FOSSIL_TEST_ASSUME(int_arg != NULL, "INT argument should be added");
98+
FOSSIL_TEST_ASSUME(int_arg->type == FOSSIL_IO_PARSER_INT, "INT argument type should be correct");
99+
100+
// Test FLOAT argument
101+
fossil_io_parser_argument_t *float_arg = fossil_io_parser_add_argument(command, "float_arg", FOSSIL_IO_PARSER_FLOAT, NULL, 0);
102+
FOSSIL_TEST_ASSUME(float_arg != NULL, "FLOAT argument should be added");
103+
FOSSIL_TEST_ASSUME(float_arg->type == FOSSIL_IO_PARSER_FLOAT, "FLOAT argument type should be correct");
104+
105+
// Test DATE argument
106+
fossil_io_parser_argument_t *date_arg = fossil_io_parser_add_argument(command, "date_arg", FOSSIL_IO_PARSER_DATE, NULL, 0);
107+
FOSSIL_TEST_ASSUME(date_arg != NULL, "DATE argument should be added");
108+
FOSSIL_TEST_ASSUME(date_arg->type == FOSSIL_IO_PARSER_DATE, "DATE argument type should be correct");
109+
110+
// Test ARRAY argument
111+
fossil_io_parser_argument_t *array_arg = fossil_io_parser_add_argument(command, "array_arg", FOSSIL_IO_PARSER_ARRAY, NULL, 0);
112+
FOSSIL_TEST_ASSUME(array_arg != NULL, "ARRAY argument should be added");
113+
FOSSIL_TEST_ASSUME(array_arg->type == FOSSIL_IO_PARSER_ARRAY, "ARRAY argument type should be correct");
114+
115+
// Test FEATURE argument
116+
fossil_io_parser_argument_t *feature_arg = fossil_io_parser_add_argument(command, "feature_arg", FOSSIL_IO_PARSER_FEATURE, NULL, 0);
117+
FOSSIL_TEST_ASSUME(feature_arg != NULL, "FEATURE argument should be added");
118+
FOSSIL_TEST_ASSUME(feature_arg->type == FOSSIL_IO_PARSER_FEATURE, "FEATURE argument type should be correct");
119+
120+
fossil_io_parser_free(palette);
121+
} // end case
122+
81123
FOSSIL_TEST_CASE(cpp_parse_command) {
82124
fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description");
83125
fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description");
@@ -165,6 +207,47 @@ FOSSIL_TEST_CASE(cpp_wrapper_free_palette) {
165207
// No explicit assumptions here, just ensuring no memory leaks or crashes
166208
} // end case
167209

210+
FOSSIL_TEST_CASE(cpp_wrapper_argument_types) {
211+
fossil::io::Parser parser;
212+
fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description");
213+
fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description");
214+
215+
// Test BOOL argument
216+
fossil_io_parser_argument_t *bool_arg = parser.add_argument(command, "bool_arg", FOSSIL_IO_PARSER_BOOL, NULL, 0);
217+
FOSSIL_TEST_ASSUME(bool_arg != NULL, "BOOL argument should be added");
218+
FOSSIL_TEST_ASSUME(bool_arg->type == FOSSIL_IO_PARSER_BOOL, "BOOL argument type should be correct");
219+
220+
// Test STRING argument
221+
fossil_io_parser_argument_t *string_arg = parser.add_argument(command, "string_arg", FOSSIL_IO_PARSER_STRING, NULL, 0);
222+
FOSSIL_TEST_ASSUME(string_arg != NULL, "STRING argument should be added");
223+
FOSSIL_TEST_ASSUME(string_arg->type == FOSSIL_IO_PARSER_STRING, "STRING argument type should be correct");
224+
225+
// Test INT argument
226+
fossil_io_parser_argument_t *int_arg = parser.add_argument(command, "int_arg", FOSSIL_IO_PARSER_INT, NULL, 0);
227+
FOSSIL_TEST_ASSUME(int_arg != NULL, "INT argument should be added");
228+
FOSSIL_TEST_ASSUME(int_arg->type == FOSSIL_IO_PARSER_INT, "INT argument type should be correct");
229+
230+
// Test FLOAT argument
231+
fossil_io_parser_argument_t *float_arg = parser.add_argument(command, "float_arg", FOSSIL_IO_PARSER_FLOAT, NULL, 0);
232+
FOSSIL_TEST_ASSUME(float_arg != NULL, "FLOAT argument should be added");
233+
FOSSIL_TEST_ASSUME(float_arg->type == FOSSIL_IO_PARSER_FLOAT, "FLOAT argument type should be correct");
234+
235+
// Test DATE argument
236+
fossil_io_parser_argument_t *date_arg = parser.add_argument(command, "date_arg", FOSSIL_IO_PARSER_DATE, NULL, 0);
237+
FOSSIL_TEST_ASSUME(date_arg != NULL, "DATE argument should be added");
238+
FOSSIL_TEST_ASSUME(date_arg->type == FOSSIL_IO_PARSER_DATE, "DATE argument type should be correct");
239+
240+
// Test ARRAY argument
241+
fossil_io_parser_argument_t *array_arg = parser.add_argument(command, "array_arg", FOSSIL_IO_PARSER_ARRAY, NULL, 0);
242+
FOSSIL_TEST_ASSUME(array_arg != NULL, "ARRAY argument should be added");
243+
FOSSIL_TEST_ASSUME(array_arg->type == FOSSIL_IO_PARSER_ARRAY, "ARRAY argument type should be correct");
244+
245+
// Test FEATURE argument
246+
fossil_io_parser_argument_t *feature_arg = parser.add_argument(command, "feature_arg", FOSSIL_IO_PARSER_FEATURE, NULL, 0);
247+
FOSSIL_TEST_ASSUME(feature_arg != NULL, "FEATURE argument should be added");
248+
FOSSIL_TEST_ASSUME(feature_arg->type == FOSSIL_IO_PARSER_FEATURE, "FEATURE argument type should be correct");
249+
parser.free(palette);
250+
} // end case
168251

169252
// * * * * * * * * * * * * * * * * * * * * * * * *
170253
// * Fossil Logic Test Pool
@@ -176,11 +259,14 @@ FOSSIL_TEST_GROUP(cpp_parser_test_cases) {
176259
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_add_argument);
177260
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_parse_command);
178261
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_free_palette);
262+
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_argument_types);
263+
179264
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_create_palette);
180265
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_add_command);
181266
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_add_argument);
182267
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_parse_command);
183268
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_free_palette);
269+
FOSSIL_TEST_ADD(cpp_parser_suite, cpp_wrapper_argument_types);
184270

185271
FOSSIL_TEST_REGISTER(cpp_parser_suite);
186272
} // end of group

0 commit comments

Comments
 (0)