tests/vector-expression.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #undef G_DISABLE_ASSERT | ||
| 2 | |||
| 3 | #include <gtk/gtk.h> | ||
| 4 | #include <shumate/shumate.h> | ||
| 5 | #include "shumate/vector/shumate-vector-expression-interpolate-private.h" | ||
| 6 | #include "shumate/vector/shumate-vector-expression-filter-private.h" | ||
| 7 | |||
| 8 | static void | ||
| 9 | 2 | test_vector_expression_parse (void) | |
| 10 | { | ||
| 11 | 4 | g_autoptr(GError) error = NULL; | |
| 12 |
1/2✗ Branch 32 → 33 not taken.
✓ Branch 32 → 34 taken 2 times.
|
4 | g_autoptr(JsonNode) node1 = json_from_string ("{\"stops\": [[12, 1], [13, 2], [14, 5], [16, 9]]}", NULL); |
| 13 |
1/2✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 32 not taken.
|
4 | g_autoptr(JsonNode) node2 = json_from_string ("1.0", NULL); |
| 14 |
1/2✓ Branch 28 → 29 taken 2 times.
✗ Branch 28 → 30 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expr1 = NULL; |
| 15 |
1/2✓ Branch 26 → 27 taken 2 times.
✗ Branch 26 → 28 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expr2 = NULL; |
| 16 |
1/2✓ Branch 24 → 25 taken 2 times.
✗ Branch 24 → 26 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expr3 = NULL; |
| 17 | |||
| 18 | 2 | expr1 = shumate_vector_expression_from_json (node1, &error); | |
| 19 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 2 times.
|
2 | g_assert_no_error (error); |
| 20 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 2 times.
|
2 | g_assert_true (SHUMATE_IS_VECTOR_EXPRESSION_INTERPOLATE (expr1)); |
| 21 | |||
| 22 | 2 | expr2 = shumate_vector_expression_from_json (node2, &error); | |
| 23 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_no_error (error); |
| 24 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_true (SHUMATE_IS_VECTOR_EXPRESSION_FILTER (expr2)); |
| 25 | |||
| 26 | 2 | expr3 = shumate_vector_expression_from_json (NULL, &error); | |
| 27 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_no_error (error); |
| 28 |
2/4✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2 times.
✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 24 not taken.
|
2 | g_assert_true (SHUMATE_IS_VECTOR_EXPRESSION_FILTER (expr3)); |
| 29 | 2 | } | |
| 30 | |||
| 31 | |||
| 32 | static void | ||
| 33 | 2 | test_vector_expression_literal (void) | |
| 34 | { | ||
| 35 | 4 | g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT; | |
| 36 | 2 | g_autoptr(ShumateVectorExpression) expr = NULL; | |
| 37 | 2 | double result; | |
| 38 | |||
| 39 | 2 | shumate_vector_value_set_number (&value, 3.1415); | |
| 40 | 2 | expr = shumate_vector_expression_filter_from_literal (&value); | |
| 41 | |||
| 42 | 2 | result = shumate_vector_expression_eval_number (expr, NULL, -10); | |
| 43 |
2/4✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 2 times.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 9 not taken.
|
2 | g_assert_cmpfloat (3.1415, ==, result); |
| 44 | 2 | } | |
| 45 | |||
| 46 | |||
| 47 | static void | ||
| 48 | 2 | test_vector_expression_number_array (void) | |
| 49 | { | ||
| 50 | 4 | g_autoptr(GError) error = NULL; | |
| 51 |
1/2✗ Branch 24 → 25 not taken.
✓ Branch 24 → 26 taken 2 times.
|
4 | g_autoptr(JsonNode) node = json_from_string ("[1, 2, 3, 4, 5]", NULL); |
| 52 |
1/2✓ Branch 22 → 23 taken 2 times.
✗ Branch 22 → 24 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 53 |
1/2✓ Branch 20 → 21 taken 2 times.
✗ Branch 20 → 22 not taken.
|
2 | g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT; |
| 54 | 2 | double num; | |
| 55 | |||
| 56 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 57 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 2 times.
|
2 | g_assert_no_error (error); |
| 58 | |||
| 59 |
1/2✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 2 times.
|
2 | g_assert_true (shumate_vector_expression_eval (expression, NULL, &value)); |
| 60 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_cmpint (5, ==, value.array->len); |
| 61 |
2/2✓ Branch 18 → 12 taken 10 times.
✓ Branch 18 → 19 taken 2 times.
|
12 | for (int i = 0; i < 5; i++) |
| 62 | { | ||
| 63 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 10 times.
|
10 | g_assert_true (shumate_vector_value_get_number (value.array->pdata[i], &num)); |
| 64 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 10 times.
|
10 | g_assert_cmpfloat (i + 1, ==, num); |
| 65 | } | ||
| 66 | 2 | } | |
| 67 | |||
| 68 | |||
| 69 | static void | ||
| 70 | 2 | test_vector_expression_nested_array_literal (void) | |
| 71 | { | ||
| 72 | 4 | g_autoptr(GError) error = NULL; | |
| 73 |
1/2✓ Branch 15 → 16 taken 2 times.
✗ Branch 15 → 17 not taken.
|
4 | g_autoptr(JsonNode) node = json_from_string ("[\"in\", 2, [1, 2, 3, 4, 5]]", NULL); |
| 74 |
1/2✓ Branch 13 → 14 taken 2 times.
✗ Branch 13 → 15 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 75 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT; |
| 76 | |||
| 77 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 78 |
3/6✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 8 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 8 not taken.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 10 taken 2 times.
|
2 | g_assert_error (error, SHUMATE_STYLE_ERROR, SHUMATE_STYLE_ERROR_INVALID_EXPRESSION); |
| 79 | 2 | } | |
| 80 | |||
| 81 | |||
| 82 | static void | ||
| 83 | 4 | check_interpolate (ShumateVectorExpression *expression) | |
| 84 | { | ||
| 85 | 4 | ShumateVectorRenderScope scope; | |
| 86 | |||
| 87 | /* Test that exact stop values work */ | ||
| 88 | 4 | scope.zoom_level = 12; | |
| 89 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 4 times.
|
4 | g_assert_cmpfloat (1.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 90 | 4 | scope.zoom_level = 13; | |
| 91 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 4 times.
|
4 | g_assert_cmpfloat (2.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 92 | 4 | scope.zoom_level = 14; | |
| 93 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
|
4 | g_assert_cmpfloat (5.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 94 | 4 | scope.zoom_level = 16; | |
| 95 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 4 times.
|
4 | g_assert_cmpfloat (9.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 96 | |||
| 97 | /* Test that outlier values work */ | ||
| 98 | 4 | scope.zoom_level = 1; | |
| 99 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 4 times.
|
4 | g_assert_cmpfloat (1.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 100 | 4 | scope.zoom_level = 100; | |
| 101 |
1/2✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 4 times.
|
4 | g_assert_cmpfloat (9.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 102 | |||
| 103 | /* Test that in-between values work */ | ||
| 104 | 4 | scope.zoom_level = 12.5; | |
| 105 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 4 times.
|
4 | g_assert_cmpfloat (1.5, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 106 | 4 | scope.zoom_level = 15; | |
| 107 |
1/2✗ Branch 24 → 25 not taken.
✓ Branch 24 → 26 taken 4 times.
|
4 | g_assert_cmpfloat (7.0, ==, shumate_vector_expression_eval_number (expression, &scope, -10000.0)); |
| 108 | 4 | } | |
| 109 | |||
| 110 | static void | ||
| 111 | 2 | test_vector_expression_interpolate (void) | |
| 112 | { | ||
| 113 | 4 | g_autoptr(GError) error = NULL; | |
| 114 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 2 times.
|
4 | g_autoptr(JsonNode) node = json_from_string ("{\"stops\": [[12, 1], [13, 2], [14, 5], [16, 9]]}", NULL); |
| 115 |
1/2✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 13 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 116 | |||
| 117 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (node); |
| 118 | |||
| 119 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 120 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 121 | |||
| 122 |
1/2✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 11 not taken.
|
2 | check_interpolate (expression); |
| 123 | 2 | } | |
| 124 | |||
| 125 | static void | ||
| 126 | 2 | test_vector_expression_interpolate_filter (void) | |
| 127 | { | ||
| 128 | 4 | g_autoptr(GError) error = NULL; | |
| 129 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 2 times.
|
4 | g_autoptr(JsonNode) node = json_from_string ("[\"interpolate\", [\"linear\"], [\"zoom\"], 12, 1, 13, 2, 14, 5, 16, 9]", NULL); |
| 130 |
1/2✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 13 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 131 | |||
| 132 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (node); |
| 133 | |||
| 134 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 135 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 136 | |||
| 137 |
1/2✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 11 not taken.
|
2 | check_interpolate (expression); |
| 138 | 2 | } | |
| 139 | |||
| 140 | |||
| 141 | static void | ||
| 142 | 4 | check_interpolate_color (ShumateVectorExpression *expression) | |
| 143 | { | ||
| 144 | 4 | ShumateVectorRenderScope scope; | |
| 145 | 4 | GdkRGBA color, correct_color; | |
| 146 | |||
| 147 | /* Test that exact stop values work */ | ||
| 148 | 4 | scope.zoom_level = 12; | |
| 149 | 4 | shumate_vector_expression_eval_color (expression, &scope, &color); | |
| 150 | 4 | gdk_rgba_parse (&correct_color, "#00224466"); | |
| 151 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 4 times.
|
4 | g_assert_true (gdk_rgba_equal (&color, &correct_color)); |
| 152 | |||
| 153 | 4 | scope.zoom_level = 12.5; | |
| 154 | 4 | shumate_vector_expression_eval_color (expression, &scope, &color); | |
| 155 | 4 | gdk_rgba_parse (&correct_color, "#446688AA"); | |
| 156 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 4 times.
|
4 | g_assert_true (gdk_rgba_equal (&color, &correct_color)); |
| 157 | |||
| 158 | 4 | scope.zoom_level = 13; | |
| 159 | 4 | shumate_vector_expression_eval_color (expression, &scope, &color); | |
| 160 | 4 | gdk_rgba_parse (&correct_color, "#88AACCEE"); | |
| 161 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 4 times.
|
4 | g_assert_true (gdk_rgba_equal (&color, &correct_color)); |
| 162 | 4 | } | |
| 163 | |||
| 164 | static void | ||
| 165 | 2 | test_vector_expression_interpolate_color (void) | |
| 166 | { | ||
| 167 | 4 | g_autoptr(GError) error = NULL; | |
| 168 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 2 times.
|
4 | g_autoptr(JsonNode) node = json_from_string ("{\"stops\": [[12, \"#00224466\"], [13, \"#88AACCEE\"]]}", NULL); |
| 169 |
1/2✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 13 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 170 | |||
| 171 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (node); |
| 172 | |||
| 173 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 174 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 175 | |||
| 176 |
1/2✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 11 not taken.
|
2 | check_interpolate_color (expression); |
| 177 | 2 | } | |
| 178 | |||
| 179 | static void | ||
| 180 | 2 | test_vector_expression_interpolate_color_filter (void) | |
| 181 | { | ||
| 182 | 4 | g_autoptr(GError) error = NULL; | |
| 183 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 2 times.
|
4 | g_autoptr(JsonNode) node = json_from_string ("[\"interpolate\", [\"linear\"], [\"zoom\"], 12, \"#00224466\", 13, \"#88AACCEE\"]", NULL); |
| 184 |
1/2✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 13 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 185 | |||
| 186 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (node); |
| 187 | |||
| 188 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 189 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 190 | |||
| 191 |
1/2✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 11 not taken.
|
2 | check_interpolate_color (expression); |
| 192 | 2 | } | |
| 193 | |||
| 194 | |||
| 195 | static gboolean | ||
| 196 | 364 | filter_with_scope (ShumateVectorRenderScope *scope, const char *filter) | |
| 197 | { | ||
| 198 | 728 | g_autoptr(GError) error = NULL; | |
| 199 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 364 times.
|
364 | g_autoptr(JsonNode) node = NULL; |
| 200 |
1/2✓ Branch 11 → 12 taken 364 times.
✗ Branch 11 → 13 not taken.
|
364 | g_autoptr(ShumateVectorExpression) expression = NULL; |
| 201 | |||
| 202 | 364 | node = json_from_string (filter, &error); | |
| 203 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 364 times.
|
364 | g_assert_no_error (error); |
| 204 | |||
| 205 | 364 | expression = shumate_vector_expression_from_json (node, &error); | |
| 206 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 364 times.
|
364 | g_assert_no_error (error); |
| 207 | |||
| 208 |
1/2✓ Branch 9 → 10 taken 364 times.
✗ Branch 9 → 11 not taken.
|
364 | return shumate_vector_expression_eval_boolean (expression, scope, FALSE); |
| 209 | } | ||
| 210 | |||
| 211 | |||
| 212 | static gboolean | ||
| 213 | 310 | filter (const char *filter) | |
| 214 | { | ||
| 215 | 310 | return filter_with_scope (NULL, filter); | |
| 216 | } | ||
| 217 | |||
| 218 | |||
| 219 | static void | ||
| 220 | 2 | test_vector_expression_basic_filter (void) | |
| 221 | { | ||
| 222 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_true (filter ("true")); |
| 223 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_false (filter ("false")); |
| 224 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_false (filter ("[\"!\", true]")); |
| 225 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_true (filter ("[\"!\", false]")); |
| 226 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 2 times.
|
2 | g_assert_true (filter ("[\"any\", false, true]")); |
| 227 |
1/2✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 2 times.
|
2 | g_assert_false (filter ("[\"any\", false, false]")); |
| 228 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 2 times.
|
2 | g_assert_true (filter ("[\"none\", false, false]")); |
| 229 |
1/2✗ Branch 24 → 25 not taken.
✓ Branch 24 → 26 taken 2 times.
|
2 | g_assert_false (filter ("[\"none\", true, false]")); |
| 230 |
1/2✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 2 times.
|
2 | g_assert_true (filter ("[\"all\", true, true]")); |
| 231 |
1/2✗ Branch 30 → 31 not taken.
✓ Branch 30 → 32 taken 2 times.
|
2 | g_assert_false (filter ("[\"all\", false, true]")); |
| 232 | |||
| 233 |
1/2✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 2 times.
|
2 | g_assert_false (filter ("[\"any\"]")); |
| 234 |
1/2✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 2 times.
|
2 | g_assert_true (filter ("[\"none\"]")); |
| 235 |
1/2✗ Branch 39 → 40 not taken.
✓ Branch 39 → 41 taken 2 times.
|
2 | g_assert_true (filter ("[\"all\"]")); |
| 236 | |||
| 237 |
1/2✗ Branch 42 → 43 not taken.
✓ Branch 42 → 44 taken 2 times.
|
2 | g_assert_true (filter ("[\"in\", 10, 20, 10, 13]")); |
| 238 |
1/2✗ Branch 45 → 46 not taken.
✓ Branch 45 → 47 taken 2 times.
|
2 | g_assert_true (filter ("[\"!in\", 10, 20, 0, 13]")); |
| 239 |
1/2✗ Branch 48 → 49 not taken.
✓ Branch 48 → 50 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"literal\", []], [\"literal\", []]]")); |
| 240 |
1/2✗ Branch 51 → 52 not taken.
✓ Branch 51 → 53 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"literal\", [10, true, \"A\", null]], [\"literal\", [10, true, \"A\", null]]]")); |
| 241 |
1/2✗ Branch 54 → 55 not taken.
✓ Branch 54 → 56 taken 2 times.
|
2 | g_assert_true (filter ("[\"in\", 13, [\"literal\", [10, 20, 0, 13]]]")); |
| 242 | |||
| 243 |
1/2✗ Branch 57 → 58 not taken.
✓ Branch 57 → 59 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", null, null]")); |
| 244 |
1/2✗ Branch 60 → 61 not taken.
✓ Branch 60 → 62 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 10, 10]")); |
| 245 |
1/2✗ Branch 63 → 64 not taken.
✓ Branch 63 → 65 taken 2 times.
|
2 | g_assert_false (filter ("[\"==\", 10, 20]")); |
| 246 |
1/2✗ Branch 66 → 67 not taken.
✓ Branch 66 → 68 taken 2 times.
|
2 | g_assert_false (filter ("[\"==\", 10, \"10\"]")); |
| 247 |
1/2✗ Branch 69 → 70 not taken.
✓ Branch 69 → 71 taken 2 times.
|
2 | g_assert_false (filter ("[\"!=\", 10, 10]")); |
| 248 |
1/2✗ Branch 72 → 73 not taken.
✓ Branch 72 → 74 taken 2 times.
|
2 | g_assert_true (filter ("[\"!=\", 10, 20]")); |
| 249 |
1/2✗ Branch 75 → 76 not taken.
✓ Branch 75 → 77 taken 2 times.
|
2 | g_assert_true (filter ("[\"!=\", 10, \"10\"]")); |
| 250 |
1/2✗ Branch 78 → 79 not taken.
✓ Branch 78 → 80 taken 2 times.
|
2 | g_assert_true (filter ("[\">\", 20, 10]")); |
| 251 |
1/2✗ Branch 81 → 82 not taken.
✓ Branch 81 → 83 taken 2 times.
|
2 | g_assert_false (filter ("[\">\", 10, 10]")); |
| 252 |
1/2✗ Branch 84 → 85 not taken.
✓ Branch 84 → 86 taken 2 times.
|
2 | g_assert_false (filter ("[\">\", 5, 10]")); |
| 253 |
1/2✗ Branch 87 → 88 not taken.
✓ Branch 87 → 89 taken 2 times.
|
2 | g_assert_true (filter ("[\"<\", 10, 20]")); |
| 254 |
1/2✗ Branch 90 → 91 not taken.
✓ Branch 90 → 92 taken 2 times.
|
2 | g_assert_false (filter ("[\"<\", 10, 10]")); |
| 255 |
1/2✗ Branch 93 → 94 not taken.
✓ Branch 93 → 95 taken 2 times.
|
2 | g_assert_false (filter ("[\"<\", 10, 5]")); |
| 256 |
1/2✗ Branch 96 → 97 not taken.
✓ Branch 96 → 98 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", 20, 10]")); |
| 257 |
1/2✗ Branch 99 → 100 not taken.
✓ Branch 99 → 101 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", 10, 10]")); |
| 258 |
1/2✗ Branch 102 → 103 not taken.
✓ Branch 102 → 104 taken 2 times.
|
2 | g_assert_false (filter ("[\">=\", 5, 10]")); |
| 259 |
1/2✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 2 times.
|
2 | g_assert_true (filter ("[\"<=\", 10, 20]")); |
| 260 |
1/2✗ Branch 108 → 109 not taken.
✓ Branch 108 → 110 taken 2 times.
|
2 | g_assert_true (filter ("[\"<=\", 10, 10]")); |
| 261 |
1/2✗ Branch 111 → 112 not taken.
✓ Branch 111 → 113 taken 2 times.
|
2 | g_assert_false (filter ("[\"<=\", 10, 5]")); |
| 262 | |||
| 263 |
1/2✗ Branch 114 → 115 not taken.
✓ Branch 114 → 116 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"case\", true, 0, 1], 0]")); |
| 264 |
1/2✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"case\", false, 0, 1], 1]")); |
| 265 |
1/2✗ Branch 120 → 121 not taken.
✓ Branch 120 → 122 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"case\", false, 0, true, 2], 2]")); |
| 266 |
1/2✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"match\", \"a\", \"b\", 2, \"c\", 3, \"a\", 1, 0], 1]")); |
| 267 |
1/2✗ Branch 126 → 127 not taken.
✓ Branch 126 → 128 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"match\", \"b\", 2], 2]")); |
| 268 |
1/2✗ Branch 129 → 130 not taken.
✓ Branch 129 → 131 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"match\", 3, [1, 2], \"x\", [3, 4, 5], \"y\", \"z\"], \"y\"]")); |
| 269 | |||
| 270 |
1/2✗ Branch 132 → 133 not taken.
✓ Branch 132 → 134 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"+\", 3, 1, 7], 11]")); |
| 271 |
1/2✗ Branch 135 → 136 not taken.
✓ Branch 135 → 137 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"-\", 3, 1], 2]")); |
| 272 |
1/2✗ Branch 138 → 139 not taken.
✓ Branch 138 → 140 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"-\", 1], -1]")); |
| 273 |
1/2✗ Branch 141 → 142 not taken.
✓ Branch 141 → 143 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"*\", 5, 6, 7], 210]")); |
| 274 |
1/2✗ Branch 144 → 145 not taken.
✓ Branch 144 → 146 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"/\", 10, 4], 2.5]")); |
| 275 |
1/2✗ Branch 147 → 148 not taken.
✓ Branch 147 → 149 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", -1, [\"%\", -21, 4]]")); |
| 276 | |||
| 277 |
1/2✗ Branch 150 → 151 not taken.
✓ Branch 150 → 152 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", 2, [\"^\", [\"e\"], [\"ln2\"]]]")); |
| 278 |
1/2✗ Branch 153 → 154 not taken.
✓ Branch 153 → 155 taken 2 times.
|
2 | g_assert_true (filter ("[\"<=\", 1.9999999999, [\"^\", [\"e\"], [\"ln2\"]]]")); |
| 279 |
1/2✗ Branch 156 → 157 not taken.
✓ Branch 156 → 158 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 1, [\"abs\", -1]]")); |
| 280 |
1/2✗ Branch 159 → 160 not taken.
✓ Branch 159 → 161 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 1, [\"abs\", 1]]")); |
| 281 |
1/2✗ Branch 162 → 163 not taken.
✓ Branch 162 → 164 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 0, [\"acos\", 1]]")); |
| 282 |
1/2✗ Branch 165 → 166 not taken.
✓ Branch 165 → 167 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 0, [\"asin\", 0]]")); |
| 283 |
1/2✗ Branch 168 → 169 not taken.
✓ Branch 168 → 170 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 0, [\"atan\", 0]]")); |
| 284 |
1/2✗ Branch 171 → 172 not taken.
✓ Branch 171 → 173 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 0, [\"ceil\", -0.5]]")); |
| 285 |
1/2✗ Branch 174 → 175 not taken.
✓ Branch 174 → 176 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", -1, [\"cos\", [\"pi\"]]]")); |
| 286 |
1/2✗ Branch 177 → 178 not taken.
✓ Branch 177 → 179 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", -1, [\"floor\", -0.5]]")); |
| 287 |
1/2✗ Branch 180 → 181 not taken.
✓ Branch 180 → 182 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 1, [\"ln\", [\"e\"]]]")); |
| 288 |
1/2✗ Branch 183 → 184 not taken.
✓ Branch 183 → 185 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 2, [\"log10\", 100]]")); |
| 289 |
1/2✗ Branch 186 → 187 not taken.
✓ Branch 186 → 188 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 6, [\"log2\", 64]]")); |
| 290 |
1/2✗ Branch 189 → 190 not taken.
✓ Branch 189 → 191 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 6, [\"max\", -10, 3, 6, -10000]]")); |
| 291 |
1/2✗ Branch 192 → 193 not taken.
✓ Branch 192 → 194 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", -10000, [\"min\", -10, 3, 6, -10000]]")); |
| 292 |
1/2✗ Branch 195 → 196 not taken.
✓ Branch 195 → 197 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 0, [\"round\", 0.49999]]")); |
| 293 |
1/2✗ Branch 198 → 199 not taken.
✓ Branch 198 → 200 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 1, [\"round\", 0.5]]")); |
| 294 |
1/2✗ Branch 201 → 202 not taken.
✓ Branch 201 → 203 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", 0.0000000000001, [\"sin\", [\"pi\"]]]")); |
| 295 |
1/2✗ Branch 204 → 205 not taken.
✓ Branch 204 → 206 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", 12, [\"sqrt\", 144]]")); |
| 296 |
1/2✗ Branch 207 → 208 not taken.
✓ Branch 207 → 209 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", 0.0000000000001, [\"tan\", [\"pi\"]]]")); |
| 297 | |||
| 298 |
1/2✗ Branch 210 → 211 not taken.
✓ Branch 210 → 212 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"coalesce\", null, [\"*\", 0, \"b\"], 2, 3], 2]")); |
| 299 |
1/2✗ Branch 213 → 214 not taken.
✓ Branch 213 → 215 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"coalesce\", null, [\"*\", 0, \"b\"]], null]")); |
| 300 |
1/2✗ Branch 216 → 217 not taken.
✓ Branch 216 → 218 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"coalesce\", \"red\"], \"red\"]")); |
| 301 | |||
| 302 |
1/2✗ Branch 219 → 220 not taken.
✓ Branch 219 → 221 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"concat\", \"hello\", 10, \"world\", true], \"hello10worldtrue\"]")); |
| 303 |
1/2✗ Branch 222 → 223 not taken.
✓ Branch 222 → 224 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"downcase\", \"HeLlO, WoRlD!\"], \"hello, world!\"]")); |
| 304 |
1/2✗ Branch 225 → 226 not taken.
✓ Branch 225 → 227 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"upcase\", \"HeLlO, WoRlD!\"], \"HELLO, WORLD!\"]")); |
| 305 |
1/2✗ Branch 228 → 229 not taken.
✓ Branch 228 → 230 taken 2 times.
|
2 | g_assert_true (filter ("[\">\", [\"literal\", \"oranges\"], \"apples\"]")); |
| 306 |
1/2✗ Branch 231 → 232 not taken.
✓ Branch 231 → 233 taken 2 times.
|
2 | g_assert_true (filter ("[\"<\", [\"literal\", \"apples\"], \"oranges\"]")); |
| 307 |
1/2✗ Branch 234 → 235 not taken.
✓ Branch 234 → 236 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", [\"literal\", \"oranges\"], \"apples\"]")); |
| 308 |
1/2✗ Branch 237 → 238 not taken.
✓ Branch 237 → 239 taken 2 times.
|
2 | g_assert_true (filter ("[\"<=\", [\"literal\", \"apples\"], \"oranges\"]")); |
| 309 |
1/2✗ Branch 240 → 241 not taken.
✓ Branch 240 → 242 taken 2 times.
|
2 | g_assert_true (filter ("[\">=\", [\"literal\", \"apples\"], \"apples\"]")); |
| 310 |
1/2✗ Branch 243 → 244 not taken.
✓ Branch 243 → 245 taken 2 times.
|
2 | g_assert_true (filter ("[\"<=\", [\"literal\", \"oranges\"], \"oranges\"]")); |
| 311 | |||
| 312 |
1/2✗ Branch 246 → 247 not taken.
✓ Branch 246 → 248 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"at\", 0, [\"literal\", [\"a\", \"b\", \"c\"]]], \"a\"]")); |
| 313 |
1/2✗ Branch 249 → 250 not taken.
✓ Branch 249 → 251 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"at\", 1, [\"literal\", [\"a\", \"b\", \"c\"]]], \"b\"]")); |
| 314 |
1/2✗ Branch 252 → 253 not taken.
✓ Branch 252 → 254 taken 2 times.
|
2 | g_assert_false (filter ("[\"==\", [\"at\", 3, [\"literal\", [\"a\", \"b\", \"c\"]]], null]")); |
| 315 |
1/2✗ Branch 255 → 256 not taken.
✓ Branch 255 → 257 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", 2, [\"literal\", [1, 2, 3]]], 1]")); |
| 316 |
1/2✗ Branch 258 → 259 not taken.
✓ Branch 258 → 260 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", 4, [\"literal\", [1, 2, 3]]], -1]")); |
| 317 |
1/2✗ Branch 261 → 262 not taken.
✓ Branch 261 → 263 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", \"!\", \"Hello, \U0001F30E!\"], 8]")); |
| 318 |
1/2✗ Branch 264 → 265 not taken.
✓ Branch 264 → 266 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", \"world\", \"Hello, world!\"], 7]")); |
| 319 |
1/2✗ Branch 267 → 268 not taken.
✓ Branch 267 → 269 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", \"WORLD\", \"Hello, world!\"], -1]")); |
| 320 |
1/2✗ Branch 270 → 271 not taken.
✓ Branch 270 → 272 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"index-of\", \"Hello\", \"Hello, world!\", 1], -1]")); |
| 321 |
1/2✗ Branch 273 → 274 not taken.
✓ Branch 273 → 275 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"length\", [\"literal\", []]], 0]")); |
| 322 |
1/2✗ Branch 276 → 277 not taken.
✓ Branch 276 → 278 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"length\", [\"literal\", [\"a\", \"b\", \"c\"]]], 3]")); |
| 323 |
1/2✗ Branch 279 → 280 not taken.
✓ Branch 279 → 281 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"length\", \"Hello, \U0001F30E!\"], 9]")); |
| 324 |
1/2✗ Branch 282 → 283 not taken.
✓ Branch 282 → 284 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 0, 2], [\"literal\", [\"a\", \"b\"]]]")); |
| 325 |
1/2✗ Branch 285 → 286 not taken.
✓ Branch 285 → 287 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 1, 2], [\"literal\", [\"b\"]]]")); |
| 326 |
1/2✗ Branch 288 → 289 not taken.
✓ Branch 288 → 290 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"Hello, \U0001F30E!\", 7], \"\U0001F30E!\"]")); |
| 327 |
1/2✗ Branch 291 → 292 not taken.
✓ Branch 291 → 293 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"Hello, \U0001F30E!\", 7, 8], \"\U0001F30E\"]")); |
| 328 | |||
| 329 | /* Test slice with negative and out of range indices */ | ||
| 330 |
1/2✗ Branch 294 → 295 not taken.
✓ Branch 294 → 296 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], -2], [\"literal\", [\"b\", \"c\"]]]")); |
| 331 |
1/2✗ Branch 297 → 298 not taken.
✓ Branch 297 → 299 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], -3], [\"literal\", [\"a\", \"b\", \"c\"]]]")); |
| 332 |
1/2✗ Branch 300 → 301 not taken.
✓ Branch 300 → 302 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], -4], [\"literal\", [\"a\", \"b\", \"c\"]]]")); |
| 333 |
1/2✗ Branch 303 → 304 not taken.
✓ Branch 303 → 305 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 0, -1], [\"literal\", [\"a\", \"b\"]]]")); |
| 334 |
1/2✗ Branch 306 → 307 not taken.
✓ Branch 306 → 308 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 0, -3], [\"literal\", []]]")); |
| 335 |
1/2✗ Branch 309 → 310 not taken.
✓ Branch 309 → 311 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 0, -4], [\"literal\", []]]")); |
| 336 |
1/2✗ Branch 312 → 313 not taken.
✓ Branch 312 → 314 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", [\"literal\", [\"a\", \"b\", \"c\"]], 3, 4], [\"literal\", []]]")); |
| 337 |
1/2✗ Branch 315 → 316 not taken.
✓ Branch 315 → 317 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", -2], \"bc\"]")); |
| 338 |
1/2✗ Branch 318 → 319 not taken.
✓ Branch 318 → 320 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", -3], \"abc\"]")); |
| 339 |
1/2✗ Branch 321 → 322 not taken.
✓ Branch 321 → 323 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", -4], \"abc\"]")); |
| 340 |
1/2✗ Branch 324 → 325 not taken.
✓ Branch 324 → 326 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", 0, -1], \"ab\"]")); |
| 341 |
1/2✗ Branch 327 → 328 not taken.
✓ Branch 327 → 329 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", 0, -3], \"\"]")); |
| 342 |
1/2✗ Branch 330 → 331 not taken.
✓ Branch 330 → 332 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", 0, -4], \"\"]")); |
| 343 |
1/2✗ Branch 333 → 334 not taken.
✓ Branch 333 → 335 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"slice\", \"abc\", 3, 4], \"\"]")); |
| 344 | |||
| 345 |
1/2✗ Branch 336 → 337 not taken.
✓ Branch 336 → 338 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"literal\", \"hello\"], \"HELLO\", [\"collator\", {\"case-sensitive\": false}]]")); |
| 346 |
1/2✗ Branch 339 → 340 not taken.
✓ Branch 339 → 341 taken 2 times.
|
2 | g_assert_true (filter ("[\"!=\", [\"literal\", \"hello\"], \"HELLO\", [\"collator\", {\"case-sensitive\": true}]]")); |
| 347 |
1/2✗ Branch 342 → 343 not taken.
✓ Branch 342 → 344 taken 2 times.
|
2 | g_assert_true (filter ("[\">\", [\"literal\", \"hello\"], \"a\", [\"collator\", {}]]")); |
| 348 |
1/2✗ Branch 345 → 346 not taken.
✓ Branch 345 → 347 taken 2 times.
|
2 | g_assert_true (filter ("[\"<\", [\"literal\", \"a\"], \"hello\", [\"collator\", {}]]")); |
| 349 |
1/2✗ Branch 348 → 349 not taken.
✓ Branch 348 → 350 taken 2 times.
|
2 | g_assert_true (filter ("[\"!=\", [\"resolved-locale\", [\"collator\", {}]], \"foo\"]")); |
| 350 | |||
| 351 |
1/2✗ Branch 351 → 352 not taken.
✓ Branch 351 → 353 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"step\", -10, \"a\", 1, \"b\", 2, \"c\"], \"a\"]")); |
| 352 |
1/2✗ Branch 354 → 355 not taken.
✓ Branch 354 → 356 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"step\", 1.5, \"a\", 1, \"b\", 2, \"c\"], \"b\"]")); |
| 353 |
1/2✗ Branch 357 → 358 not taken.
✓ Branch 357 → 359 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"step\", 2, \"a\", 1, \"b\", 2, \"c\"], \"c\"]")); |
| 354 |
1/2✗ Branch 360 → 361 not taken.
✓ Branch 360 → 362 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"step\", 3, \"a\", 1, \"b\", 2, \"c\"], \"c\"]")); |
| 355 | |||
| 356 |
1/2✗ Branch 363 → 364 not taken.
✓ Branch 363 → 365 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", 0], false]")); |
| 357 |
1/2✗ Branch 366 → 367 not taken.
✓ Branch 366 → 368 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", 1], true]")); |
| 358 |
1/2✗ Branch 369 → 370 not taken.
✓ Branch 369 → 371 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", -2], true]")); |
| 359 |
1/2✗ Branch 372 → 373 not taken.
✓ Branch 372 → 374 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", null], false]")); |
| 360 |
1/2✗ Branch 375 → 376 not taken.
✓ Branch 375 → 377 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", \"\"], false]")); |
| 361 |
1/2✗ Branch 378 → 379 not taken.
✓ Branch 378 → 380 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", \"hello\"], true]")); |
| 362 |
1/2✗ Branch 381 → 382 not taken.
✓ Branch 381 → 383 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", [\"collator\", {}]], true]")); |
| 363 |
1/2✗ Branch 384 → 385 not taken.
✓ Branch 384 → 386 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-color\", \"red\"], [\"to-color\", \"rgb(255, 0, 0)\"]]")); |
| 364 |
1/2✗ Branch 387 → 388 not taken.
✓ Branch 387 → 389 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-color\", \"not a color\", \"#FF0000\"], [\"to-color\", \"rgb(255, 0, 0)\"]]")); |
| 365 |
1/2✗ Branch 390 → 391 not taken.
✓ Branch 390 → 392 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", \"2\"], 2]")); |
| 366 |
1/2✗ Branch 393 → 394 not taken.
✓ Branch 393 → 395 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", \"-.5\"], -0.5]")); |
| 367 |
1/2✗ Branch 396 → 397 not taken.
✓ Branch 396 → 398 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", \"1e3\"], 1000]")); |
| 368 |
1/2✗ Branch 399 → 400 not taken.
✓ Branch 399 → 401 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", null], 0]")); |
| 369 |
1/2✗ Branch 402 → 403 not taken.
✓ Branch 402 → 404 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", false], 0]")); |
| 370 |
1/2✗ Branch 405 → 406 not taken.
✓ Branch 405 → 407 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", true], 1]")); |
| 371 |
1/2✗ Branch 408 → 409 not taken.
✓ Branch 408 → 410 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-number\", \"not a number\", 10], 10]")); |
| 372 |
1/2✗ Branch 411 → 412 not taken.
✓ Branch 411 → 413 taken 2 times.
|
2 | g_assert_false (filter ("[\"==\", 2, \"2\"]")); |
| 373 |
1/2✗ Branch 414 → 415 not taken.
✓ Branch 414 → 416 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", 2], \"2\"]")); |
| 374 |
1/2✗ Branch 417 → 418 not taken.
✓ Branch 417 → 419 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", \"a\"], \"a\"]")); |
| 375 |
1/2✗ Branch 420 → 421 not taken.
✓ Branch 420 → 422 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", true], \"true\"]")); |
| 376 |
1/2✗ Branch 423 → 424 not taken.
✓ Branch 423 → 425 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", false], \"false\"]")); |
| 377 |
1/2✗ Branch 426 → 427 not taken.
✓ Branch 426 → 428 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", null], \"\"]")); |
| 378 |
1/2✗ Branch 429 → 430 not taken.
✓ Branch 429 → 431 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"to-color\", \"gold\"]], \"rgba(255,215,0,1)\"]")); |
| 379 |
1/2✗ Branch 432 → 433 not taken.
✓ Branch 432 → 434 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"to-color\", \"rgba(255, 1, 2, 0.1)\"]], \"rgba(255,1,2,0.1)\"]")); |
| 380 |
1/2✗ Branch 435 → 436 not taken.
✓ Branch 435 → 437 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"literal\", [1, 0.5, null, true, [\"b\"]]]], \"[1,0.5,null,true,[\\\"b\\\"]]\"]")); |
| 381 | |||
| 382 | /* Test NaN/inf handling */ | ||
| 383 |
1/2✗ Branch 438 → 439 not taken.
✓ Branch 438 → 440 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", [\"/\", 0, 0]], false]")); |
| 384 |
1/2✗ Branch 441 → 442 not taken.
✓ Branch 441 → 443 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-boolean\", [\"/\", 1, 0]], true]")); |
| 385 |
1/2✗ Branch 444 → 445 not taken.
✓ Branch 444 → 446 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"/\", 0, 0]], \"NaN\"]")); |
| 386 |
1/2✗ Branch 447 → 448 not taken.
✓ Branch 447 → 449 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"/\", 1, 0]], \"Infinity\"]")); |
| 387 |
1/2✗ Branch 450 → 451 not taken.
✓ Branch 450 → 452 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"/\", -1, 0]], \"-Infinity\"]")); |
| 388 |
1/2✗ Branch 453 → 454 not taken.
✓ Branch 453 → 455 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"%\", 0, 0]], \"NaN\"]")); |
| 389 |
1/2✗ Branch 456 → 457 not taken.
✓ Branch 456 → 458 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"%\", 1, 0]], \"NaN\"]")); |
| 390 |
1/2✗ Branch 459 → 460 not taken.
✓ Branch 459 → 461 taken 2 times.
|
2 | g_assert_true (filter ("[\"==\", [\"to-string\", [\"%\", -1, 0]], \"NaN\"]")); |
| 391 | 2 | } | |
| 392 | |||
| 393 | |||
| 394 | static void | ||
| 395 | 2 | test_vector_expression_variable_binding (void) | |
| 396 | { | ||
| 397 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_true (filter ("[\"let\", \"a\", [\"-\", 15, 5], \"b\", 20, [\"==\", 30, [\"+\", [\"var\", \"a\"], [\"var\", \"b\"]]]]")); |
| 398 | |||
| 399 | /* Test nesting */ | ||
| 400 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_true (filter ("[\"let\", \"a\", 10, [\"==\", 20, [\"let\", \"a\", 20, [\"var\", \"a\"]]]]")); |
| 401 | 2 | } | |
| 402 | |||
| 403 | |||
| 404 | static void | ||
| 405 | 2 | test_vector_expression_global_state (void) | |
| 406 | { | ||
| 407 | 2 | ShumateVectorRenderScope scope; | |
| 408 | 2 | ShumateVectorValue* value; | |
| 409 | 2 | g_autoptr(GHashTable) global_state = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)shumate_vector_value_free); | |
| 410 | |||
| 411 | 2 | scope.global_state = global_state; | |
| 412 | |||
| 413 | 2 | value = shumate_vector_value_new_number (5); | |
| 414 | 2 | g_hash_table_insert (scope.global_state, g_strdup ("blah"), value); | |
| 415 | |||
| 416 |
1/2✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", [\"global-state\", \"blah\"], 5]")); |
| 417 |
2/4✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 2 times.
✓ Branch 12 → 13 taken 2 times.
✗ Branch 12 → 14 not taken.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"==\", [\"global-state\", null], 10]")); |
| 418 | 2 | } | |
| 419 | |||
| 420 | |||
| 421 | static void | ||
| 422 | 2 | test_vector_expression_image (void) | |
| 423 | { | ||
| 424 | 4 | g_autoptr(GdkTexture) texture = NULL; | |
| 425 |
1/2✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 25 not taken.
|
2 | g_autoptr(GBytes) json_data = NULL; |
| 426 | 2 | GError *error = NULL; | |
| 427 | 2 | ShumateVectorRenderScope scope; | |
| 428 | |||
| 429 | 2 | texture = gdk_texture_new_from_resource ("/org/gnome/shumate/Tests/sprites.png"); | |
| 430 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_no_error (error); |
| 431 | 2 | json_data = g_resources_lookup_data ("/org/gnome/shumate/Tests/sprites.json", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 432 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 433 | |||
| 434 | 2 | scope.sprites = shumate_vector_sprite_sheet_new (); | |
| 435 | 2 | scope.scale_factor = 1; | |
| 436 | 2 | shumate_vector_sprite_sheet_add_page (scope.sprites, texture, g_bytes_get_data (json_data, NULL), 1, &error); | |
| 437 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_no_error (error); |
| 438 | |||
| 439 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", null, [\"image\", \"sprite\"]]")); |
| 440 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", null, [\"image\", \"does-not-exist\"]]")); |
| 441 | |||
| 442 |
2/4✓ Branch 19 → 20 taken 2 times.
✗ Branch 19 → 21 not taken.
✓ Branch 21 → 22 taken 2 times.
✗ Branch 21 → 23 not taken.
|
2 | g_clear_object (&scope.sprites); |
| 443 | 2 | } | |
| 444 | |||
| 445 | |||
| 446 | static void | ||
| 447 | 2 | test_vector_expression_feature_filter (void) | |
| 448 | { | ||
| 449 | 2 | GError *error = NULL; | |
| 450 | 4 | g_autoptr(GBytes) vector_data = NULL; | |
| 451 |
1/2✓ Branch 86 → 87 taken 2 times.
✗ Branch 86 → 88 not taken.
|
2 | g_autoptr(ShumateVectorReader) reader = NULL; |
| 452 | 2 | ShumateVectorRenderScope scope; | |
| 453 | |||
| 454 | 2 | vector_data = g_resources_lookup_data ("/org/gnome/shumate/Tests/0.pbf", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 455 | 2 | g_assert_no_error (error); | |
| 456 | |||
| 457 | 2 | reader = shumate_vector_reader_new (vector_data); | |
| 458 | 2 | scope.reader = shumate_vector_reader_iterate (reader); | |
| 459 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 2 times.
|
2 | g_assert_nonnull (scope.reader); |
| 460 | |||
| 461 | 2 | scope.zoom_level = 10; | |
| 462 | |||
| 463 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_read_layer_by_name (scope.reader, "helloworld")); |
| 464 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (scope.reader)); |
| 465 | |||
| 466 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", \"name\", \"Hello, world!\"]")); |
| 467 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", [\"get\", \"name\"], \"Hello, world!\"]")); |
| 468 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", [\"get\", \"name\"], \"HELLO, WORLD!\"]")); |
| 469 |
1/2✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 2 times.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"==\", \"name\", \"Goodbye, world!\"]")); |
| 470 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"has\", \"name\"]")); |
| 471 | // Use concat to avoid optimizations and test the regular code path | ||
| 472 |
1/2✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", [\"get\", [\"concat\", \"name\"]], \"Hello, world!\"]")); |
| 473 |
1/2✗ Branch 32 → 33 not taken.
✓ Branch 32 → 34 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"has\", [\"concat\", \"name\"]]")); |
| 474 |
1/2✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 2 times.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"!has\", \"name\"]")); |
| 475 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 2 times.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"!has\", [\"concat\", \"name\"]]")); |
| 476 |
1/2✗ Branch 41 → 42 not taken.
✓ Branch 41 → 43 taken 2 times.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"has\", \"name:en\"]")); |
| 477 |
1/2✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!has\", \"name:en\"]")); |
| 478 |
1/2✗ Branch 47 → 48 not taken.
✓ Branch 47 → 49 taken 2 times.
|
2 | g_assert_false (filter_with_scope (&scope, "[\"has\", [\"concat\", \"name:en\"]]")); |
| 479 |
1/2✗ Branch 50 → 51 not taken.
✓ Branch 50 → 52 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!has\", [\"concat\", \"name:en\"]]")); |
| 480 |
1/2✗ Branch 53 → 54 not taken.
✓ Branch 53 → 55 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", \"$type\", \"Point\"]")); |
| 481 |
1/2✗ Branch 56 → 57 not taken.
✓ Branch 56 → 58 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", \"$type\", \"Polygon\"]")); |
| 482 |
1/2✗ Branch 59 → 60 not taken.
✓ Branch 59 → 61 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", \"$type\", \"NotAShape\"]")); |
| 483 |
1/2✗ Branch 62 → 63 not taken.
✓ Branch 62 → 64 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", [\"geometry-type\"], [\"concat\", \"Point\"]]")); |
| 484 |
1/2✗ Branch 65 → 66 not taken.
✓ Branch 65 → 67 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", [\"geometry-type\"], [\"concat\", \"Polygon\"]]")); |
| 485 |
1/2✗ Branch 68 → 69 not taken.
✓ Branch 68 → 70 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", \"zoom\", 10]")); |
| 486 |
1/2✗ Branch 71 → 72 not taken.
✓ Branch 71 → 73 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"in\", \"name\", [\"literal\", [\"Hello, world!\", true, 3]]]")); |
| 487 |
1/2✗ Branch 74 → 75 not taken.
✓ Branch 74 → 76 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!in\", \"name\", [\"literal\", [\"HELLO, WORLD!\", true, 3]]]")); |
| 488 |
1/2✗ Branch 77 → 78 not taken.
✓ Branch 77 → 79 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"==\", [\"concat\", \"Hello, world!\"], \"Hello, world!\"]")); |
| 489 |
1/2✗ Branch 80 → 81 not taken.
✓ Branch 80 → 82 taken 2 times.
|
2 | g_assert_true (filter_with_scope (&scope, "[\"!=\", [\"concat\", \"Hello, world!\"], \"HELLO, WORLD!\"]")); |
| 490 | |||
| 491 |
2/4✓ Branch 82 → 83 taken 2 times.
✗ Branch 82 → 84 not taken.
✓ Branch 84 → 85 taken 2 times.
✗ Branch 84 → 86 not taken.
|
2 | g_clear_object (&scope.reader); |
| 492 | 2 | } | |
| 493 | |||
| 494 | |||
| 495 | static void | ||
| 496 | 20 | filter_expect_error (const char *filter) | |
| 497 | { | ||
| 498 | 40 | g_autoptr(GError) error = NULL; | |
| 499 |
1/2✓ Branch 16 → 17 taken 20 times.
✗ Branch 16 → 18 not taken.
|
40 | g_autoptr(JsonNode) node = json_from_string (filter, NULL); |
| 500 |
1/2✓ Branch 14 → 15 taken 20 times.
✗ Branch 14 → 16 not taken.
|
40 | g_autoptr(ShumateVectorExpression) expression = shumate_vector_expression_from_json (node, &error); |
| 501 | |||
| 502 |
3/6✓ Branch 4 → 5 taken 20 times.
✗ Branch 4 → 8 not taken.
✓ Branch 6 → 7 taken 20 times.
✗ Branch 6 → 8 not taken.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 10 taken 20 times.
|
20 | g_assert_error (error, SHUMATE_STYLE_ERROR, SHUMATE_STYLE_ERROR_INVALID_EXPRESSION); |
| 503 |
2/4✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 20 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 20 times.
|
20 | g_assert_null (expression); |
| 504 | 20 | } | |
| 505 | |||
| 506 | static void | ||
| 507 | 2 | test_vector_expression_filter_errors (void) | |
| 508 | { | ||
| 509 | 2 | filter_expect_error ("[\"not an operator\"]"); | |
| 510 | 2 | filter_expect_error ("[\"in\"]"); | |
| 511 | 2 | filter_expect_error ("[\"==\", 0, 1, 2, 3]"); | |
| 512 | 2 | filter_expect_error ("[]"); | |
| 513 | 2 | filter_expect_error ("[[]]"); | |
| 514 | |||
| 515 | 2 | filter_expect_error ("[\"+\"]"); | |
| 516 | 2 | filter_expect_error ("[\"-\", 1, 2, 3]"); | |
| 517 | 2 | filter_expect_error ("[\"/\", 1, 2, 3]"); | |
| 518 | 2 | filter_expect_error ("[\"abs\", 1, 2]"); | |
| 519 | 2 | filter_expect_error ("[\"%\", 1]"); | |
| 520 | 2 | } | |
| 521 | |||
| 522 | |||
| 523 | static void | ||
| 524 | 2 | test_vector_expression_format () | |
| 525 | { | ||
| 526 | 2 | GError *error = NULL; | |
| 527 | 4 | g_autoptr(GBytes) vector_data = NULL; | |
| 528 |
1/2✓ Branch 32 → 33 taken 2 times.
✗ Branch 32 → 34 not taken.
|
2 | g_autoptr(ShumateVectorReader) reader = NULL; |
| 529 | 2 | ShumateVectorRenderScope scope; | |
| 530 |
1/2✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 32 not taken.
|
4 | g_autoptr(JsonNode) node = json_from_string ("\"***** {name} *****\"", NULL); |
| 531 |
1/2✓ Branch 28 → 29 taken 2 times.
✗ Branch 28 → 30 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression; |
| 532 |
1/2✓ Branch 26 → 27 taken 2 times.
✗ Branch 26 → 28 not taken.
|
2 | g_autofree char *result = NULL; |
| 533 | |||
| 534 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 535 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 2 times.
|
2 | g_assert_no_error (error); |
| 536 | |||
| 537 | 2 | vector_data = g_resources_lookup_data ("/org/gnome/shumate/Tests/0.pbf", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 538 |
1/2✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 2 times.
|
2 | g_assert_no_error (error); |
| 539 | |||
| 540 | 2 | reader = shumate_vector_reader_new (vector_data); | |
| 541 | 2 | scope.reader = shumate_vector_reader_iterate (reader); | |
| 542 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_nonnull (scope.reader); |
| 543 | |||
| 544 | 2 | scope.zoom_level = 10; | |
| 545 | |||
| 546 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_read_layer_by_name (scope.reader, "helloworld")); |
| 547 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (scope.reader)); |
| 548 | |||
| 549 | 2 | result = shumate_vector_expression_eval_string (expression, &scope, NULL); | |
| 550 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 2 times.
|
2 | g_assert_cmpstr (result, ==, "***** Hello, world! *****"); |
| 551 | |||
| 552 |
1/2✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 25 not taken.
|
2 | g_clear_object (&scope.reader); |
| 553 | 2 | } | |
| 554 | |||
| 555 | |||
| 556 | static void | ||
| 557 | 2 | test_vector_expression_array () | |
| 558 | { | ||
| 559 | 4 | g_autofree char *string = NULL; | |
| 560 | 2 | g_auto(ShumateVectorValue) element1 = SHUMATE_VECTOR_VALUE_INIT; | |
| 561 | 2 | g_auto(ShumateVectorValue) element2 = SHUMATE_VECTOR_VALUE_INIT; | |
| 562 | 2 | g_auto(ShumateVectorValue) array1 = SHUMATE_VECTOR_VALUE_INIT; | |
| 563 | 2 | g_auto(ShumateVectorValue) array2 = SHUMATE_VECTOR_VALUE_INIT; | |
| 564 | |||
| 565 | 2 | g_autoptr(GError) error = NULL; | |
| 566 |
1/2✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 2 times.
|
2 | g_autoptr(JsonNode) node = NULL; |
| 567 |
1/2✓ Branch 32 → 33 taken 2 times.
✗ Branch 32 → 34 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression = NULL; |
| 568 |
1/2✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 32 not taken.
|
2 | g_auto(ShumateVectorValue) eval = SHUMATE_VECTOR_VALUE_INIT; |
| 569 | |||
| 570 | 2 | shumate_vector_value_set_string (&element1, "Hello, world!"); | |
| 571 | 2 | shumate_vector_value_set_boolean (&element2, TRUE); | |
| 572 | |||
| 573 | 2 | shumate_vector_value_start_array (&array1); | |
| 574 | 2 | shumate_vector_value_array_append (&array1, &element1); | |
| 575 | 2 | shumate_vector_value_array_append (&array1, &element2); | |
| 576 | |||
| 577 | 2 | string = shumate_vector_value_as_string (&array1); | |
| 578 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_cmpstr (string, ==, "[\"Hello, world!\",true]"); |
| 579 | |||
| 580 | 2 | shumate_vector_value_start_array (&array2); | |
| 581 | 2 | shumate_vector_value_array_append (&array2, &element1); | |
| 582 | 2 | shumate_vector_value_array_append (&array2, &element2); | |
| 583 | |||
| 584 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_equal (&array1, &array2)); |
| 585 | |||
| 586 | 2 | shumate_vector_value_array_append (&array2, &element1); | |
| 587 |
1/2✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 2 times.
|
2 | g_assert_false (shumate_vector_value_equal (&array1, &array2)); |
| 588 | |||
| 589 | 2 | node = json_from_string ("[\"literal\", [\"Hello, world!\", true, \"Hello, world!\"]]", NULL); | |
| 590 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 591 |
1/2✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 2 times.
|
2 | g_assert_no_error (error); |
| 592 | 2 | shumate_vector_expression_eval (expression, NULL, &eval); | |
| 593 | |||
| 594 |
1/2✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_equal (&eval, &array2)); |
| 595 | 2 | } | |
| 596 | |||
| 597 | |||
| 598 | static void | ||
| 599 | 2 | test_vector_expression_formatted_string () | |
| 600 | { | ||
| 601 | 4 | g_autoptr(GError) error = NULL; | |
| 602 |
1/2✗ Branch 64 → 65 not taken.
✓ Branch 64 → 66 taken 2 times.
|
2 | g_autoptr(JsonNode) node = NULL; |
| 603 |
1/2✓ Branch 62 → 63 taken 2 times.
✗ Branch 62 → 64 not taken.
|
2 | g_autoptr(ShumateVectorExpression) expression = NULL; |
| 604 |
1/2✓ Branch 60 → 61 taken 2 times.
✗ Branch 60 → 62 not taken.
|
2 | g_auto(ShumateVectorValue) eval = SHUMATE_VECTOR_VALUE_INIT; |
| 605 | 2 | g_autofree char *as_string = NULL; | |
| 606 | 2 | GPtrArray *format_parts = NULL; | |
| 607 | 2 | ShumateVectorFormatPart *part = NULL; | |
| 608 | |||
| 609 | 2 | node = json_from_string ("[\"format\",\ | |
| 610 | \"Hello \",\ | ||
| 611 | [\"concat\", \"world\", \"!\"], {\"font-scale\": 0.1},\ | ||
| 612 | \"\\n\", {\"text-color\": [\"coalesce\", \"red\"]},\ | ||
| 613 | null,\ | ||
| 614 | \"test\"\ | ||
| 615 | ]", &error); | ||
| 616 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_no_error (error); |
| 617 | 2 | expression = shumate_vector_expression_from_json (node, &error); | |
| 618 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_no_error (error); |
| 619 | |||
| 620 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_true (shumate_vector_expression_eval (expression, NULL, &eval)); |
| 621 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_get_formatted (&eval, &format_parts)); |
| 622 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_cmpint (format_parts->len, ==, 4); |
| 623 | |||
| 624 | 2 | as_string = shumate_vector_value_as_string (&eval); | |
| 625 |
1/2✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 2 times.
|
2 | g_assert_cmpstr (as_string, ==, "Hello world!\ntest"); |
| 626 | |||
| 627 | 2 | part = format_parts->pdata[0]; | |
| 628 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 2 times.
|
2 | g_assert_cmpstr (part->string, ==, "Hello "); |
| 629 |
1/2✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 2 times.
|
2 | g_assert_null (part->sprite); |
| 630 |
1/2✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 2 times.
|
2 | g_assert_false (part->has_font_scale); |
| 631 |
1/2✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 2 times.
|
2 | g_assert_false (part->has_text_color); |
| 632 | |||
| 633 | 2 | part = format_parts->pdata[1]; | |
| 634 |
1/2✗ Branch 30 → 31 not taken.
✓ Branch 30 → 32 taken 2 times.
|
2 | g_assert_cmpstr (part->string, ==, "world!"); |
| 635 |
1/2✗ Branch 32 → 33 not taken.
✓ Branch 32 → 34 taken 2 times.
|
2 | g_assert_null (part->sprite); |
| 636 |
1/2✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 2 times.
|
2 | g_assert_true (part->has_font_scale); |
| 637 |
1/2✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 2 times.
|
2 | g_assert_cmpfloat (part->font_scale, ==, 0.1); |
| 638 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 2 times.
|
2 | g_assert_false (part->has_text_color); |
| 639 | |||
| 640 | 2 | part = format_parts->pdata[2]; | |
| 641 |
1/2✗ Branch 41 → 42 not taken.
✓ Branch 41 → 43 taken 2 times.
|
2 | g_assert_cmpstr (part->string, ==, "\n"); |
| 642 |
1/2✗ Branch 43 → 44 not taken.
✓ Branch 43 → 45 taken 2 times.
|
2 | g_assert_null (part->sprite); |
| 643 |
1/2✗ Branch 45 → 46 not taken.
✓ Branch 45 → 47 taken 2 times.
|
2 | g_assert_false (part->has_font_scale); |
| 644 |
1/2✗ Branch 47 → 48 not taken.
✓ Branch 47 → 49 taken 2 times.
|
2 | g_assert_true (part->has_text_color); |
| 645 | |||
| 646 | 2 | part = format_parts->pdata[3]; | |
| 647 |
1/2✗ Branch 50 → 51 not taken.
✓ Branch 50 → 52 taken 2 times.
|
2 | g_assert_cmpstr (part->string, ==, "test"); |
| 648 |
1/2✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 2 times.
|
2 | g_assert_null (part->sprite); |
| 649 |
1/2✗ Branch 54 → 55 not taken.
✓ Branch 54 → 56 taken 2 times.
|
2 | g_assert_false (part->has_font_scale); |
| 650 |
1/2✗ Branch 56 → 57 not taken.
✓ Branch 56 → 58 taken 2 times.
|
2 | g_assert_false (part->has_text_color); |
| 651 | 2 | } | |
| 652 | |||
| 653 | |||
| 654 | int | ||
| 655 | 2 | main (int argc, char *argv[]) | |
| 656 | { | ||
| 657 | 2 | g_test_init (&argc, &argv, NULL); | |
| 658 | |||
| 659 | 2 | g_test_add_func ("/vector/expression/parse", test_vector_expression_parse); | |
| 660 | 2 | g_test_add_func ("/vector/expression/literal", test_vector_expression_literal); | |
| 661 | 2 | g_test_add_func ("/vector/expression/number-array", test_vector_expression_number_array); | |
| 662 | 2 | g_test_add_func ("/vector/expression/nested-array-literal", test_vector_expression_nested_array_literal); | |
| 663 | 2 | g_test_add_func ("/vector/expression/interpolate", test_vector_expression_interpolate); | |
| 664 | 2 | g_test_add_func ("/vector/expression/interpolate-filter", test_vector_expression_interpolate_filter); | |
| 665 | 2 | g_test_add_func ("/vector/expression/interpolate-color", test_vector_expression_interpolate_color); | |
| 666 | 2 | g_test_add_func ("/vector/expression/interpolate-color-filter", test_vector_expression_interpolate_color_filter); | |
| 667 | 2 | g_test_add_func ("/vector/expression/basic-filter", test_vector_expression_basic_filter); | |
| 668 | 2 | g_test_add_func ("/vector/expression/variable-binding", test_vector_expression_variable_binding); | |
| 669 | 2 | g_test_add_func ("/vector/expression/global-state", test_vector_expression_global_state); | |
| 670 | 2 | g_test_add_func ("/vector/expression/image", test_vector_expression_image); | |
| 671 | 2 | g_test_add_func ("/vector/expression/feature-filter", test_vector_expression_feature_filter); | |
| 672 | 2 | g_test_add_func ("/vector/expression/filter-errors", test_vector_expression_filter_errors); | |
| 673 | 2 | g_test_add_func ("/vector/expression/format", test_vector_expression_format); | |
| 674 | 2 | g_test_add_func ("/vector/expression/array", test_vector_expression_array); | |
| 675 | 2 | g_test_add_func ("/vector/expression/formatted-string", test_vector_expression_formatted_string); | |
| 676 | |||
| 677 | 2 | return g_test_run (); | |
| 678 | } | ||
| 679 |