37 |
37 |
38 |
38 |
39 UCX_TEST(test_expr_parse_expr_value) { |
39 UCX_TEST(test_expr_parse_expr_value) { |
40 pool_handle_t *pool = pool_create(); |
40 pool_handle_t *pool = pool_create(); |
41 |
41 |
42 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
42 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
43 cxstring token = cx_str("123"); |
43 cxstring token = cx_str("123"); |
44 cxListAdd(tokens, &token); |
44 cxListAdd(tokens, &token); |
45 |
45 |
46 UCX_TEST_BEGIN; |
46 UCX_TEST_BEGIN; |
47 |
47 |
58 } |
58 } |
59 |
59 |
60 UCX_TEST(test_expr_parse_expr_neg_value) { |
60 UCX_TEST(test_expr_parse_expr_neg_value) { |
61 pool_handle_t *pool = pool_create(); |
61 pool_handle_t *pool = pool_create(); |
62 |
62 |
63 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
63 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
64 cxstring token = cx_str("-123"); |
64 cxstring token = cx_str("-123"); |
65 cxListAdd(tokens, &token); |
65 cxListAdd(tokens, &token); |
66 |
66 |
67 UCX_TEST_BEGIN; |
67 UCX_TEST_BEGIN; |
68 |
68 |
80 } |
80 } |
81 |
81 |
82 UCX_TEST(test_expr_parse_expr_value_str) { |
82 UCX_TEST(test_expr_parse_expr_value_str) { |
83 pool_handle_t *pool = pool_create(); |
83 pool_handle_t *pool = pool_create(); |
84 |
84 |
85 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
85 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
86 cxstring token = cx_str("\"hello world\""); |
86 cxstring token = cx_str("\"hello world\""); |
87 cxListAdd(tokens, &token); |
87 cxListAdd(tokens, &token); |
88 |
88 |
89 UCX_TEST_BEGIN; |
89 UCX_TEST_BEGIN; |
90 |
90 |
102 } |
102 } |
103 |
103 |
104 UCX_TEST(test_expr_parse_expr_value_bool) { |
104 UCX_TEST(test_expr_parse_expr_value_bool) { |
105 pool_handle_t *pool = pool_create(); |
105 pool_handle_t *pool = pool_create(); |
106 |
106 |
107 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
107 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
108 cxstring token = cx_str("true"); |
108 cxstring token = cx_str("true"); |
109 cxListAdd(tokens, &token); |
109 cxListAdd(tokens, &token); |
110 |
110 |
111 UCX_TEST_BEGIN; |
111 UCX_TEST_BEGIN; |
112 |
112 |
124 } |
124 } |
125 |
125 |
126 UCX_TEST(test_expr_parse_expr_value_var) { |
126 UCX_TEST(test_expr_parse_expr_value_var) { |
127 pool_handle_t *pool = pool_create(); |
127 pool_handle_t *pool = pool_create(); |
128 |
128 |
129 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
129 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
130 cxstring token = cx_str("$test"); |
130 cxstring token = cx_str("$test"); |
131 cxListAdd(tokens, &token); |
131 cxListAdd(tokens, &token); |
132 |
132 |
133 UCX_TEST_BEGIN; |
133 UCX_TEST_BEGIN; |
134 |
134 |
146 } |
146 } |
147 |
147 |
148 UCX_TEST(test_expr_parse_expr_not_value) { |
148 UCX_TEST(test_expr_parse_expr_not_value) { |
149 pool_handle_t *pool = pool_create(); |
149 pool_handle_t *pool = pool_create(); |
150 |
150 |
151 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
151 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
152 cxstring token = cx_str("not"); |
152 cxstring token = cx_str("not"); |
153 cxListAdd(tokens, &token); |
153 cxListAdd(tokens, &token); |
154 token = cx_str("true"); |
154 token = cx_str("true"); |
155 cxListAdd(tokens, &token); |
155 cxListAdd(tokens, &token); |
156 |
156 |
174 } |
174 } |
175 |
175 |
176 UCX_TEST(test_expr_parse_expr_sign_value) { |
176 UCX_TEST(test_expr_parse_expr_sign_value) { |
177 pool_handle_t *pool = pool_create(); |
177 pool_handle_t *pool = pool_create(); |
178 |
178 |
179 CxList *tokens1 = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
179 CxList *tokens1 = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
180 cxstring token = cx_str("+"); |
180 cxstring token = cx_str("+"); |
181 cxListAdd(tokens1, &token); |
181 cxListAdd(tokens1, &token); |
182 token = cx_str("123"); |
182 token = cx_str("123"); |
183 cxListAdd(tokens1, &token); |
183 cxListAdd(tokens1, &token); |
184 |
184 |
185 CxList *tokens2 = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
185 CxList *tokens2 = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
186 token = cx_str("-"); |
186 token = cx_str("-"); |
187 cxListAdd(tokens2, &token); |
187 cxListAdd(tokens2, &token); |
188 token = cx_str("123"); |
188 token = cx_str("123"); |
189 cxListAdd(tokens2, &token); |
189 cxListAdd(tokens2, &token); |
190 |
190 |
216 |
216 |
217 |
217 |
218 UCX_TEST(test_expr_parse_expr_compare2values) { |
218 UCX_TEST(test_expr_parse_expr_compare2values) { |
219 pool_handle_t *pool = pool_create(); |
219 pool_handle_t *pool = pool_create(); |
220 |
220 |
221 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
221 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
222 cxstring token = cx_str("2"); |
222 cxstring token = cx_str("2"); |
223 cxListAdd(tokens, &token); |
223 cxListAdd(tokens, &token); |
224 token = cx_str("=="); |
224 token = cx_str("=="); |
225 cxListAdd(tokens, &token); |
225 cxListAdd(tokens, &token); |
226 token = cx_str("2"); |
226 token = cx_str("2"); |
247 } |
247 } |
248 |
248 |
249 UCX_TEST(test_expr_parse_expr_compare2value_expr) { |
249 UCX_TEST(test_expr_parse_expr_compare2value_expr) { |
250 pool_handle_t *pool = pool_create(); |
250 pool_handle_t *pool = pool_create(); |
251 |
251 |
252 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
252 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
253 cxstring token = cx_str("2"); |
253 cxstring token = cx_str("2"); |
254 cxListAdd(tokens, &token); |
254 cxListAdd(tokens, &token); |
255 token = cx_str("=="); |
255 token = cx_str("=="); |
256 cxListAdd(tokens, &token); |
256 cxListAdd(tokens, &token); |
257 token = cx_str("1"); |
257 token = cx_str("1"); |
282 } |
282 } |
283 |
283 |
284 UCX_TEST(test_expr_parse_expr_compare2expr_value) { |
284 UCX_TEST(test_expr_parse_expr_compare2expr_value) { |
285 pool_handle_t *pool = pool_create(); |
285 pool_handle_t *pool = pool_create(); |
286 |
286 |
287 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
287 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
288 cxstring token = cx_str("1"); |
288 cxstring token = cx_str("1"); |
289 cxListAdd(tokens, &token); |
289 cxListAdd(tokens, &token); |
290 token = cx_str("+"); |
290 token = cx_str("+"); |
291 cxListAdd(tokens, &token); |
291 cxListAdd(tokens, &token); |
292 token = cx_str("1"); |
292 token = cx_str("1"); |
323 |
323 |
324 UCX_TEST(test_expr_parse_expr_bracket) { |
324 UCX_TEST(test_expr_parse_expr_bracket) { |
325 pool_handle_t *pool = pool_create(); |
325 pool_handle_t *pool = pool_create(); |
326 |
326 |
327 // expression: 2 * (1 + 2) == 6 |
327 // expression: 2 * (1 + 2) == 6 |
328 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
328 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
329 cxstring token = cx_str("2"); |
329 cxstring token = cx_str("2"); |
330 cxListAdd(tokens, &token); |
330 cxListAdd(tokens, &token); |
331 token = cx_str("*"); |
331 token = cx_str("*"); |
332 cxListAdd(tokens, &token); |
332 cxListAdd(tokens, &token); |
333 token = cx_str("("); |
333 token = cx_str("("); |
369 } |
369 } |
370 |
370 |
371 UCX_TEST(test_expr_op_defined_simple) { |
371 UCX_TEST(test_expr_op_defined_simple) { |
372 pool_handle_t *pool = pool_create(); |
372 pool_handle_t *pool = pool_create(); |
373 |
373 |
374 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
374 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
375 cxstring token = cx_str("defined"); |
375 cxstring token = cx_str("defined"); |
376 cxListAdd(tokens, &token); |
376 cxListAdd(tokens, &token); |
377 |
377 |
378 token = cx_str("$testvar1"); |
378 token = cx_str("$testvar1"); |
379 cxListAdd(tokens, &token); |
379 cxListAdd(tokens, &token); |
396 } |
396 } |
397 |
397 |
398 UCX_TEST(test_expr_op_defined) { |
398 UCX_TEST(test_expr_op_defined) { |
399 pool_handle_t *pool = pool_create(); |
399 pool_handle_t *pool = pool_create(); |
400 |
400 |
401 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
401 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
402 cxstring token = cx_str("true"); |
402 cxstring token = cx_str("true"); |
403 cxListAdd(tokens, &token); |
403 cxListAdd(tokens, &token); |
404 |
404 |
405 token = cx_str("=="); |
405 token = cx_str("=="); |
406 cxListAdd(tokens, &token); |
406 cxListAdd(tokens, &token); |
435 } |
435 } |
436 |
436 |
437 UCX_TEST(test_expr_op_file_exists_simple) { |
437 UCX_TEST(test_expr_op_file_exists_simple) { |
438 pool_handle_t *pool = pool_create(); |
438 pool_handle_t *pool = pool_create(); |
439 |
439 |
440 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
440 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
441 cxstring token = cx_str("-e"); |
441 cxstring token = cx_str("-e"); |
442 cxListAdd(tokens, &token); |
442 cxListAdd(tokens, &token); |
443 |
443 |
444 token = cx_str("\"/path/file\""); |
444 token = cx_str("\"/path/file\""); |
445 cxListAdd(tokens, &token); |
445 cxListAdd(tokens, &token); |
463 } |
463 } |
464 |
464 |
465 UCX_TEST(test_expr_parse_expr_func_arg0) { |
465 UCX_TEST(test_expr_parse_expr_func_arg0) { |
466 pool_handle_t *pool = pool_create(); |
466 pool_handle_t *pool = pool_create(); |
467 |
467 |
468 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
468 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
469 cxstring token = cx_str("test"); |
469 cxstring token = cx_str("test"); |
470 cxListAdd(tokens, &token); |
470 cxListAdd(tokens, &token); |
471 token = cx_str("("); |
471 token = cx_str("("); |
472 cxListAdd(tokens, &token); |
472 cxListAdd(tokens, &token); |
473 token = cx_str(")"); |
473 token = cx_str(")"); |
519 |
519 |
520 |
520 |
521 UCX_TEST(test_expr_parse_expr_func_arg1) { |
521 UCX_TEST(test_expr_parse_expr_func_arg1) { |
522 pool_handle_t *pool = pool_create(); |
522 pool_handle_t *pool = pool_create(); |
523 |
523 |
524 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
524 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
525 cxstring token = cx_str("test"); |
525 cxstring token = cx_str("test"); |
526 cxListAdd(tokens, &token); |
526 cxListAdd(tokens, &token); |
527 token = cx_str("("); |
527 token = cx_str("("); |
528 cxListAdd(tokens, &token); |
528 cxListAdd(tokens, &token); |
529 token = cx_str("1"); |
529 token = cx_str("1"); |
554 } |
554 } |
555 |
555 |
556 UCX_TEST(test_expr_parse_expr_func_arg3) { |
556 UCX_TEST(test_expr_parse_expr_func_arg3) { |
557 pool_handle_t *pool = pool_create(); |
557 pool_handle_t *pool = pool_create(); |
558 |
558 |
559 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
559 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
560 cxstring token = cx_str("test"); |
560 cxstring token = cx_str("test"); |
561 cxListAdd(tokens, &token); |
561 cxListAdd(tokens, &token); |
562 token = cx_str("("); |
562 token = cx_str("("); |
563 cxListAdd(tokens, &token); |
563 cxListAdd(tokens, &token); |
564 token = cx_str("1"); |
564 token = cx_str("1"); |
599 } |
599 } |
600 |
600 |
601 UCX_TEST(test_expr_parse_expr_func_expr1) { |
601 UCX_TEST(test_expr_parse_expr_func_expr1) { |
602 pool_handle_t *pool = pool_create(); |
602 pool_handle_t *pool = pool_create(); |
603 |
603 |
604 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
604 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
605 cxstring token = cx_str("test"); |
605 cxstring token = cx_str("test"); |
606 cxListAdd(tokens, &token); |
606 cxListAdd(tokens, &token); |
607 token = cx_str("("); |
607 token = cx_str("("); |
608 cxListAdd(tokens, &token); |
608 cxListAdd(tokens, &token); |
609 token = cx_str("1"); |
609 token = cx_str("1"); |
645 } |
645 } |
646 |
646 |
647 UCX_TEST(test_expr_parse_expr_func_expr2) { |
647 UCX_TEST(test_expr_parse_expr_func_expr2) { |
648 pool_handle_t *pool = pool_create(); |
648 pool_handle_t *pool = pool_create(); |
649 |
649 |
650 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxstring)); |
650 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); |
651 cxstring token = cx_str("test"); |
651 cxstring token = cx_str("test"); |
652 cxListAdd(tokens, &token); |
652 cxListAdd(tokens, &token); |
653 token = cx_str("("); |
653 token = cx_str("("); |
654 cxListAdd(tokens, &token); |
654 cxListAdd(tokens, &token); |
655 token = cx_str("2"); |
655 token = cx_str("2"); |