203 amxc_var_t* subtable;
204 amxc_var_t* subarray;
209 {
true,
"'brown' in CSVText"},
210 {
true,
"TextField == \"This is text\"" },
211 {
true,
"MyTable.Text == \"Hello World\"" },
212 {
true,
".MyTable.Number == 100" },
213 {
true,
"MyTable.Boolean" },
214 {
true,
"MyArray.0 == \"Item1\""},
215 {
true,
".MyArray.1 == \"-20000\""},
216 {
true,
"MyArray.2"},
217 {
true,
"MyArray.3 > \"1970-01-01T00:00:00Z\""},
218 {
true,
"\"This is text\" == TextField" },
219 {
true,
"\"Hello World\" == MyTable.Text;" },
220 {
true,
"100 == MyTable.Number" },
221 {
true,
"\"Item1\" == MyArray.0"},
222 {
true,
"\"-20000\" == MyArray.1;"},
223 {
true,
"\"1970-01-01T00:00:00Z\" < MyArray.3"},
224 {
false,
"MyTable.Number > MyArray.1" },
225 {
true,
"MyArray.1 < MyTable.Number" },
226 {
true,
"TextField matches \"This.*\""},
227 {
false,
"TextField matches \"Not This.*\""},
228 {
true,
"TextField starts with 'This'"},
229 {
false,
"TextField starts with 'But Not This'"},
230 {
true,
"'fox' in CSVText"},
231 {
false,
"'red' in CSVText"}
234 amxc_var_init(&data);
235 amxc_var_set_type(&data, AMXC_VAR_ID_HTABLE);
238 amxc_var_add_key(cstring_t, &data,
"TextField",
"This is text");
239 subtable = amxc_var_add_key(amxc_htable_t, &data,
"MyTable", NULL);
240 amxc_var_add_key(cstring_t, subtable,
"Text",
"Hello World");
241 amxc_var_add_key(uint32_t, subtable,
"Number", 100);
242 amxc_var_add_key(
bool, subtable,
"Boolean",
true);
243 subarray = amxc_var_add_key(amxc_llist_t, &data,
"MyArray", NULL);
244 amxc_var_add(cstring_t, subarray,
"Item1");
245 amxc_var_add(int64_t, subarray, -20000);
246 amxc_var_add(
bool, subarray,
true);
247 amxc_var_add(amxc_ts_t, subarray, &now);
248 amxc_var_add_key(csv_string_t, &data,
"CSVText",
"The,big,brown,fox,jumped");
250 printf(
"Test data = ");
252 amxc_var_dump(&data, STDOUT_FILENO);
254 for(uint32_t i = 0; i <
sizeof(evals) /
sizeof(evals[0]); i++) {
256 printf(
"Evaluating \"%s\" (expecting %s - ", evals[i].text, evals[i].result ?
"true" :
"false");
261 assert_int_equal(status, 0);
262 printf(
"got %s)\n", result ?
"true" :
"false");
264 assert_true(result == evals[i].result);
268 subarray = GETP_ARG(&data,
"CSVText");
269 assert_int_equal(amxc_var_type_of(subarray), AMXC_VAR_ID_CSV_STRING);
271 amxc_var_clean(&data);
bool amxp_expr_eval_var(amxp_expr_t *expr, const amxc_var_t *const data, amxp_expr_status_t *status)
Evaluates an expression against a composite variant.
void amxp_expr_dump_tree(amxp_expr_t *expr)
Dumps the binary tree in dot formatted text file to stdout.