--- a/src/server/test/object.c Sat Nov 22 12:49:20 2025 +0100 +++ b/src/server/test/object.c Sat Nov 22 14:27:01 2025 +0100 @@ -36,116 +36,116 @@ #include "object.h" -UCX_TEST(test_expr_parse_expr_value) { +CX_TEST(test_expr_parse_expr_value) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); cxstring token = cx_str("123"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 1, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_INT, "wrong type"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 1); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_INT); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_neg_value) { +CX_TEST(test_expr_parse_expr_neg_value) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); cxstring token = cx_str("-123"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 1, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_INT, "wrong type"); - UCX_TEST_ASSERT(expr->value.i == -123, "wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 1); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_INT); + CX_TEST_ASSERT(expr->value.i == -123); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_value_str) { +CX_TEST(test_expr_parse_expr_value_str) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); cxstring token = cx_str("\"hello world\""); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 1, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_STRING, "wrong type"); - UCX_TEST_ASSERT(!cx_strcmp(expr->value.str, cx_str("hello world")), "wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 1); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_STRING); + CX_TEST_ASSERT(!cx_strcmp(expr->value.str, cx_str("hello world"))); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_value_bool) { +CX_TEST(test_expr_parse_expr_value_bool) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); cxstring token = cx_str("true"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 1, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BOOL, "wrong type"); - UCX_TEST_ASSERT(expr->value.b == 1, "wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 1); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BOOL); + CX_TEST_ASSERT(expr->value.b == 1); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_value_var) { +CX_TEST(test_expr_parse_expr_value_var) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); cxstring token = cx_str("$test"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 1, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_VARIABLE, "wrong type"); - UCX_TEST_ASSERT(!cx_strcmp(expr->value.var, cx_str("test")), "wrong var name"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 1); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_VARIABLE); + CX_TEST_ASSERT(!cx_strcmp(expr->value.var, cx_str("test"))); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_not_value) { +CX_TEST(test_expr_parse_expr_not_value) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -154,26 +154,26 @@ token = cx_str("true"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == 2, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); + CX_TEST_DO { - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY, "wrong root expression type"); - UCX_TEST_ASSERT(expr->left, "missing left expression"); - UCX_TEST_ASSERT(!expr->right, "right expression should be null"); - UCX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_BOOL, "left expression has wrong type"); - UCX_TEST_ASSERT(expr->left->value.b == 1, "left expression has wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 2); + CX_TEST_ASSERT(expr); + + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(!expr->right); + CX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_BOOL); + CX_TEST_ASSERT(expr->left->value.b == 1); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_sign_value) { +CX_TEST(test_expr_parse_expr_sign_value) { pool_handle_t *pool = pool_create(); CxList *tokens1 = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -188,34 +188,34 @@ token = cx_str("123"); cxListAdd(tokens2, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens1, &pos); - - UCX_TEST_ASSERT(pos == 2, "test1: wrong token pos"); - UCX_TEST_ASSERT(expr, "test1: expression is null"); - - pos = 0; - expr = expr_parse_logical_expr(pool, tokens2, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 2, "test2: wrong token pos"); - UCX_TEST_ASSERT(expr, "test2: expression is null"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens1, &pos); + + CX_TEST_ASSERT(pos == 2); + CX_TEST_ASSERT(expr); + + pos = 0; + expr = expr_parse_logical_expr(pool, tokens2, &pos); + + CX_TEST_ASSERT(pos == 2); + CX_TEST_ASSERT(expr); + + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_SUB); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_INT); + CX_TEST_ASSERT(expr->left->value.i == 123); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_SUB, "wrong expression operator"); - UCX_TEST_ASSERT(expr->left, "missing left expresion"); - UCX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_INT, "left expression has wrong type"); - UCX_TEST_ASSERT(expr->left->value.i == 123, "left expression has wrong value"); - - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_compare2values) { +CX_TEST(test_expr_parse_expr_compare2values) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -226,27 +226,27 @@ token = cx_str("2"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == 3, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); + CX_TEST_DO { - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY, "wrong expression type"); - UCX_TEST_ASSERT(expr->left, "left expression is null"); - UCX_TEST_ASSERT(expr->right, "right expression is null"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 3); + CX_TEST_ASSERT(expr); + + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->right); + + CX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_NOOP); + CX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOOP); - UCX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_NOOP, "left should be a literal with no operator"); - UCX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOOP, "right should be a literal with no operator"); - - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_compare2value_expr) { +CX_TEST(test_expr_parse_expr_compare2value_expr) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -261,27 +261,27 @@ token = cx_str("1"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == 5, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); + CX_TEST_DO { - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY, "wrong expression type"); - UCX_TEST_ASSERT(expr->left, "left expression is null"); - UCX_TEST_ASSERT(expr->right, "right expression is null"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 5); + CX_TEST_ASSERT(expr); + + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->right); + + CX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_NOOP); + CX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_ADD); - UCX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_NOOP, "left should be a literal with no operator"); - UCX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_ADD, "right should be a binary expression"); - - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_compare2expr_value) { +CX_TEST(test_expr_parse_expr_compare2expr_value) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -296,32 +296,32 @@ token = cx_str("2"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == 5, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); + CX_TEST_DO { - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY, "wrong expression type"); - UCX_TEST_ASSERT(expr->left, "left expression is null"); - UCX_TEST_ASSERT(expr->right, "right expression is null"); - UCX_TEST_ASSERT(expr->right->value.i == 2, "right wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 5); + CX_TEST_ASSERT(expr); + + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_BINARY); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->right); + CX_TEST_ASSERT(expr->right->value.i == 2); + + CX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_ADD); + CX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOOP); + CX_TEST_ASSERT(expr->left->left); + CX_TEST_ASSERT(expr->left->right); + CX_TEST_ASSERT(expr->left->left->value.i == 1); + CX_TEST_ASSERT(expr->left->right->value.i == 1); - UCX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_ADD, "left should be a binary operation"); - UCX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOOP, "right should be NOOP"); - UCX_TEST_ASSERT(expr->left->left, "ADD-op missing left"); - UCX_TEST_ASSERT(expr->left->right, "ADD-op missing right"); - UCX_TEST_ASSERT(expr->left->left->value.i == 1, "ADD-op: wrong left value"); - UCX_TEST_ASSERT(expr->left->right->value.i == 1, "ADD-op: wrong right value"); - - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_bracket) { +CX_TEST(test_expr_parse_expr_bracket) { pool_handle_t *pool = pool_create(); // expression: 2 * (1 + 2) == 6 @@ -345,30 +345,30 @@ token = cx_str("6"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 9, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_EQ, "root: wrong operator"); - UCX_TEST_ASSERT(expr->left, "missing left expression"); - UCX_TEST_ASSERT(expr->right, "missing right expression"); - UCX_TEST_ASSERT(expr->right->type == NSAPI_EXPRESSION_INT, "right expression has wrong type"); - UCX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_MUL, "left expression has wrong operator"); - UCX_TEST_ASSERT(expr->left->left, "mul: missing left"); - UCX_TEST_ASSERT(expr->left->right, "mul: missing right"); - UCX_TEST_ASSERT(expr->left->right->operator == NSAPI_EXPRESSION_ADD, "missing add operator"); - UCX_TEST_ASSERT(expr->left->right->left, "add: missing left"); - UCX_TEST_ASSERT(expr->left->right->left, "add: missing right"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 9); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_EQ); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->right); + CX_TEST_ASSERT(expr->right->type == NSAPI_EXPRESSION_INT); + CX_TEST_ASSERT(expr->left->operator == NSAPI_EXPRESSION_MUL); + CX_TEST_ASSERT(expr->left->left); + CX_TEST_ASSERT(expr->left->right); + CX_TEST_ASSERT(expr->left->right->operator == NSAPI_EXPRESSION_ADD); + CX_TEST_ASSERT(expr->left->right->left); + CX_TEST_ASSERT(expr->left->right->left); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_op_defined_simple) { +CX_TEST(test_expr_op_defined_simple) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -378,24 +378,24 @@ token = cx_str("$testvar1"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 2, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY, "wrong type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_VALUE_DEFINED, "wrong operator"); - UCX_TEST_ASSERT(expr->left, "missing left operand"); - UCX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_VARIABLE, "operand is not a variable"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 2); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_VALUE_DEFINED); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_VARIABLE); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_op_defined) { +CX_TEST(test_expr_op_defined) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -414,27 +414,27 @@ token = cx_str("$var"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 5, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_EQ, "wrong operator"); - UCX_TEST_ASSERT(expr->left, "missing left"); - UCX_TEST_ASSERT(expr->right, "missing right"); - UCX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_BOOL, "left expression is not a bool"); - UCX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOT, "right: wrong operator"); - UCX_TEST_ASSERT(expr->right->left, "not op: missing left"); - UCX_TEST_ASSERT(expr->right->left->operator == NSAPI_EXPRESSION_VALUE_DEFINED, "missing defined operator"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 5); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_EQ); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->right); + CX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_BOOL); + CX_TEST_ASSERT(expr->right->operator == NSAPI_EXPRESSION_NOT); + CX_TEST_ASSERT(expr->right->left); + CX_TEST_ASSERT(expr->right->left->operator == NSAPI_EXPRESSION_VALUE_DEFINED); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_op_file_exists_simple) { +CX_TEST(test_expr_op_file_exists_simple) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -444,25 +444,25 @@ token = cx_str("\"/path/file\""); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 2, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY, "wrong type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_FILE_DIR_EXISTS, "wrong operator"); - UCX_TEST_ASSERT(expr->left, "missing left operand"); - UCX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_STRING, "operand is not a string"); - UCX_TEST_ASSERT(!cx_strcmp(expr->left->value.str, cx_str("/path/file")), "wrong string operand"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 2); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_UNARY); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_FILE_DIR_EXISTS); + CX_TEST_ASSERT(expr->left); + CX_TEST_ASSERT(expr->left->type == NSAPI_EXPRESSION_STRING); + CX_TEST_ASSERT(!cx_strcmp(expr->left->value.str, cx_str("/path/file"))); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_func_arg0) { +CX_TEST(test_expr_parse_expr_func_arg0) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -473,19 +473,19 @@ token = cx_str(")"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == 3, "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL, "wrong expression operator"); - UCX_TEST_ASSERT(!expr->left, "left is not null"); - UCX_TEST_ASSERT(!expr->right, "right is not null"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == 3); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL); + CX_TEST_ASSERT(!expr->left); + CX_TEST_ASSERT(!expr->right); - UCX_TEST_END; + } pool_destroy(pool); } @@ -518,7 +518,7 @@ } -UCX_TEST(test_expr_parse_expr_func_arg1) { +CX_TEST(test_expr_parse_expr_func_arg1) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -531,29 +531,29 @@ token = cx_str(")"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + CX_TEST_DO { - UCX_TEST_ASSERT(pos == cxListSize(tokens), "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL, "wrong expression operator"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == cxListSize(tokens)); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL); + + size_t numArgs = 0; + NSAPIExpression args[8]; + int err = test_get_args(args, 8, &numArgs, expr->left); + CX_TEST_ASSERT(err == 0); + CX_TEST_ASSERT(numArgs == 1); + CX_TEST_ASSERT(args[0].value.i == 1); - size_t numArgs = 0; - NSAPIExpression args[8]; - int err = test_get_args(args, 8, &numArgs, expr->left); - UCX_TEST_ASSERT(err == 0, "too much args"); - UCX_TEST_ASSERT(numArgs == 1, "wrong arg count"); - UCX_TEST_ASSERT(args[0].value.i == 1, "wrong arg value"); - - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_func_arg3) { +CX_TEST(test_expr_parse_expr_func_arg3) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -574,31 +574,31 @@ token = cx_str(")"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == cxListSize(tokens), "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL, "wrong expression operator"); + CX_TEST_DO { - size_t numArgs = 0; - NSAPIExpression args[8]; - int err = test_get_args(args, 8, &numArgs, expr->left); - UCX_TEST_ASSERT(err == 0, "too much args"); - UCX_TEST_ASSERT(numArgs == 3, "wrong arg count"); - UCX_TEST_ASSERT(args[0].value.i == 1, "arg0: wrong value"); - UCX_TEST_ASSERT(args[1].value.i == 2, "arg1: wrong value"); - UCX_TEST_ASSERT(args[2].value.i == 3, "arg2: wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == cxListSize(tokens)); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL); + + size_t numArgs = 0; + NSAPIExpression args[8]; + int err = test_get_args(args, 8, &numArgs, expr->left); + CX_TEST_ASSERT(err == 0); + CX_TEST_ASSERT(numArgs == 3); + CX_TEST_ASSERT(args[0].value.i == 1); + CX_TEST_ASSERT(args[1].value.i == 2); + CX_TEST_ASSERT(args[2].value.i == 3); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_func_expr1) { +CX_TEST(test_expr_parse_expr_func_expr1) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -619,32 +619,32 @@ token = cx_str(")"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == cxListSize(tokens), "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL, "wrong expression operator"); + CX_TEST_DO { - size_t numArgs = 0; - NSAPIExpression args[8]; - int err = test_get_args(args, 8, &numArgs, expr->left); - UCX_TEST_ASSERT(err == 0, "too much args"); - UCX_TEST_ASSERT(numArgs == 2, "wrong arg count"); - UCX_TEST_ASSERT(args[0].value.i == 1, "arg0: wrong value"); - UCX_TEST_ASSERT(args[1].operator == NSAPI_EXPRESSION_ADD, "arg1: wrong operator"); - UCX_TEST_ASSERT(args[1].left && args[1].right, "arg1: missing operator values"); - UCX_TEST_ASSERT(args[1].left->value.i == 2 && args[1].right->value.i == 3, "arg1: wrong operator values"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == cxListSize(tokens)); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL); + + size_t numArgs = 0; + NSAPIExpression args[8]; + int err = test_get_args(args, 8, &numArgs, expr->left); + CX_TEST_ASSERT(err == 0); + CX_TEST_ASSERT(numArgs == 2); + CX_TEST_ASSERT(args[0].value.i == 1); + CX_TEST_ASSERT(args[1].operator == NSAPI_EXPRESSION_ADD); + CX_TEST_ASSERT(args[1].left && args[1].right); + CX_TEST_ASSERT(args[1].left->value.i == 2 && args[1].right->value.i == 3); - UCX_TEST_END; + } pool_destroy(pool); } -UCX_TEST(test_expr_parse_expr_func_expr2) { +CX_TEST(test_expr_parse_expr_func_expr2) { pool_handle_t *pool = pool_create(); CxList *tokens = cxLinkedListCreate(pool_allocator(pool), NULL, sizeof(cxstring)); @@ -675,29 +675,29 @@ token = cx_str(")"); cxListAdd(tokens, &token); - UCX_TEST_BEGIN; - - size_t pos = 0; - NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); - - UCX_TEST_ASSERT(pos == cxListSize(tokens), "wrong token pos"); - UCX_TEST_ASSERT(expr, "expression is null"); - UCX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER, "wrong expression type"); - UCX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL, "wrong expression operator"); + CX_TEST_DO { - size_t numArgs = 0; - NSAPIExpression args[8]; - int err = test_get_args(args, 8, &numArgs, expr->left); - UCX_TEST_ASSERT(err == 0, "too much args"); - UCX_TEST_ASSERT(numArgs == 3, "wrong arg count"); - UCX_TEST_ASSERT(args[0].operator == NSAPI_EXPRESSION_ADD, "arg0: wrong operator"); - UCX_TEST_ASSERT(args[0].left && args[0].right, "arg0: missing operator values"); - UCX_TEST_ASSERT(args[1].operator == NSAPI_EXPRESSION_CALL, "arg1: wrong operator"); - UCX_TEST_ASSERT(args[1].left, "arg1: missing args"); - UCX_TEST_ASSERT(args[2].type == NSAPI_EXPRESSION_INT, "arg2: wrong type"); - UCX_TEST_ASSERT(args[2].value.i == 6, "arg2: wrong value"); + size_t pos = 0; + NSAPIExpression *expr = expr_parse_logical_expr(pool, tokens, &pos); + + CX_TEST_ASSERT(pos == cxListSize(tokens)); + CX_TEST_ASSERT(expr); + CX_TEST_ASSERT(expr->type == NSAPI_EXPRESSION_IDENTIFIER); + CX_TEST_ASSERT(expr->operator == NSAPI_EXPRESSION_CALL); + + size_t numArgs = 0; + NSAPIExpression args[8]; + int err = test_get_args(args, 8, &numArgs, expr->left); + CX_TEST_ASSERT(err == 0); + CX_TEST_ASSERT(numArgs == 3); + CX_TEST_ASSERT(args[0].operator == NSAPI_EXPRESSION_ADD); + CX_TEST_ASSERT(args[0].left && args[0].right); + CX_TEST_ASSERT(args[1].operator == NSAPI_EXPRESSION_CALL); + CX_TEST_ASSERT(args[1].left); + CX_TEST_ASSERT(args[2].type == NSAPI_EXPRESSION_INT); + CX_TEST_ASSERT(args[2].value.i == 6); - UCX_TEST_END; + } pool_destroy(pool); }