| 1 |
/* WirePlumber |
| 2 |
* |
| 3 |
* Copyright © 2021 Collabora Ltd. |
| 4 |
* @author Julian Bouzas <[email protected]> |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: MIT |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "../common/test-log.h" |
| 10 |
|
| 11 |
static void |
| 12 |
test_spa_json_basic (void) |
| 13 |
{ |
| 14 |
/* Null */ |
| 15 |
{ |
| 16 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_null (); |
| 17 |
g_assert_nonnull (json); |
| 18 |
g_assert_true (wp_spa_json_is_null (json)); |
| 19 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 20 |
"null", 4); |
| 21 |
} |
| 22 |
|
| 23 |
/* Boolean */ |
| 24 |
{ |
| 25 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_boolean (TRUE); |
| 26 |
g_assert_nonnull (json); |
| 27 |
g_assert_true (wp_spa_json_is_boolean (json)); |
| 28 |
gboolean v = FALSE; |
| 29 |
g_assert_true (wp_spa_json_parse_boolean (json, &v)); |
| 30 |
g_assert_true (v); |
| 31 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 32 |
"true", 4); |
| 33 |
} |
| 34 |
|
| 35 |
/* Int */ |
| 36 |
{ |
| 37 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_int (8); |
| 38 |
g_assert_nonnull (json); |
| 39 |
g_assert_true (wp_spa_json_is_int (json)); |
| 40 |
gint32 v = 0; |
| 41 |
g_assert_true (wp_spa_json_parse_int (json, &v)); |
| 42 |
g_assert_cmpint (v, ==, 8); |
| 43 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 44 |
"8", 1); |
| 45 |
} |
| 46 |
|
| 47 |
/* Float */ |
| 48 |
{ |
| 49 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_float (3.14f); |
| 50 |
g_assert_nonnull (json); |
| 51 |
g_assert_true (wp_spa_json_is_float (json)); |
| 52 |
float v = 0; |
| 53 |
g_assert_true (wp_spa_json_parse_float (json, &v)); |
| 54 |
g_assert_cmpfloat_with_epsilon (v, 3.14f, 0.001f); |
| 55 |
} |
| 56 |
|
| 57 |
/* String */ |
| 58 |
{ |
| 59 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_string ("wireplumber"); |
| 60 |
g_assert_nonnull (json); |
| 61 |
g_assert_true (wp_spa_json_is_string (json)); |
| 62 |
g_autofree gchar *v1 = wp_spa_json_parse_string (json); |
| 63 |
g_assert_nonnull (v1); |
| 64 |
g_assert_cmpstr (v1, ==, "wireplumber"); |
| 65 |
|
| 66 |
g_autoptr (WpSpaJson) jsone = wp_spa_json_new_string (""); |
| 67 |
g_assert_nonnull (jsone); |
| 68 |
g_assert_true (wp_spa_json_is_string (jsone)); |
| 69 |
g_autofree gchar *v2 = wp_spa_json_parse_string (jsone); |
| 70 |
g_assert_nonnull (v2); |
| 71 |
g_assert_cmpstr (v2, ==, ""); |
| 72 |
|
| 73 |
g_autoptr (WpSpaJson) jsonl = wp_spa_json_new_string ( |
| 74 |
"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"); |
| 75 |
g_assert_nonnull (jsonl); |
| 76 |
g_assert_true (wp_spa_json_is_string (jsonl)); |
| 77 |
g_autofree gchar *v3 = wp_spa_json_parse_string (jsonl); |
| 78 |
g_assert_nonnull (v3); |
| 79 |
g_assert_cmpstr (v3, ==, |
| 80 |
"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"); |
| 81 |
|
| 82 |
g_autoptr (WpSpaJson) jsons = wp_spa_json_new_string ("\v\v\v\v"); |
| 83 |
g_assert_nonnull (jsons); |
| 84 |
g_assert_true (wp_spa_json_is_string (jsons)); |
| 85 |
g_autofree gchar *v4 = wp_spa_json_parse_string (jsons); |
| 86 |
g_assert_nonnull (v4); |
| 87 |
g_assert_cmpstr (v4, ==, "\v\v\v\v"); |
| 88 |
} |
| 89 |
|
| 90 |
/* Array */ |
| 91 |
{ |
| 92 |
g_autoptr (WpSpaJson) empty = wp_spa_json_new_array (NULL, NULL); |
| 93 |
g_assert_nonnull (empty); |
| 94 |
g_assert_true (wp_spa_json_is_array (empty)); |
| 95 |
g_assert_cmpmem (wp_spa_json_get_data (empty), wp_spa_json_get_size (empty), |
| 96 |
"[]", 2); |
| 97 |
|
| 98 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_array ("i", 1, "i", 2, NULL); |
| 99 |
g_assert_nonnull (json); |
| 100 |
g_assert_true (wp_spa_json_is_array (json)); |
| 101 |
gint32 v1 = 0, v2 = 0; |
| 102 |
g_assert_true (wp_spa_json_parse_array (json, "i", &v1, "i", &v2, NULL)); |
| 103 |
g_assert_cmpint (v1, ==, 1); |
| 104 |
g_assert_cmpint (v2, ==, 2); |
| 105 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 106 |
"[1, 2]", 6); |
| 107 |
} |
| 108 |
|
| 109 |
/* Object */ |
| 110 |
{ |
| 111 |
g_autoptr (WpSpaJson) empty = wp_spa_json_new_object (NULL, NULL, NULL); |
| 112 |
g_assert_nonnull (empty); |
| 113 |
g_assert_true (wp_spa_json_is_object (empty)); |
| 114 |
g_assert_cmpmem (wp_spa_json_get_data (empty), wp_spa_json_get_size (empty), |
| 115 |
"{}", 2); |
| 116 |
|
| 117 |
g_autoptr (WpSpaJson) subjson = wp_spa_json_new_array ("b", TRUE, NULL); |
| 118 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_object ( |
| 119 |
"key1", "n", |
| 120 |
"key2", "b", TRUE, |
| 121 |
"key3", "i", 3, |
| 122 |
"key4", "f", 2.72f, |
| 123 |
"key5", "s", "str", |
| 124 |
"key6", "J", subjson, |
| 125 |
NULL); |
| 126 |
g_assert_nonnull (json); |
| 127 |
g_assert_true (wp_spa_json_is_object (json)); |
| 128 |
|
| 129 |
{ |
| 130 |
g_autofree gchar *key1 = NULL, *key2 = NULL, *key3 = NULL, *key4 = NULL, |
| 131 |
*key5 = NULL, *key6 = NULL; |
| 132 |
gboolean v2 = FALSE; |
| 133 |
gint32 v3 = 0; |
| 134 |
float v4 = 0.0f; |
| 135 |
g_autofree gchar *v5 = NULL; |
| 136 |
g_autoptr (WpSpaJson) v6 = NULL; |
| 137 |
g_assert_true (wp_spa_json_parse_object (json, |
| 138 |
&key1, "n", |
| 139 |
&key2, "b", &v2, |
| 140 |
&key3, "i", &v3, |
| 141 |
&key4, "f", &v4, |
| 142 |
&key5, "s", &v5, |
| 143 |
&key6, "J", &v6, |
| 144 |
NULL)); |
| 145 |
g_assert_cmpstr (key1, ==, "key1"); |
| 146 |
g_assert_cmpstr (key2, ==, "key2"); |
| 147 |
g_assert_true (v2); |
| 148 |
g_assert_cmpstr (key3, ==, "key3"); |
| 149 |
g_assert_cmpint (v3, ==, 3); |
| 150 |
g_assert_cmpstr (key4, ==, "key4"); |
| 151 |
g_assert_cmpfloat_with_epsilon (v4, 2.72f, 0.001f); |
| 152 |
g_assert_cmpstr (key5, ==, "key5"); |
| 153 |
g_assert_cmpstr (v5, ==, "str"); |
| 154 |
g_assert_cmpstr (key6, ==, "key6"); |
| 155 |
g_assert_nonnull (v6); |
| 156 |
g_assert_cmpmem (wp_spa_json_get_data (v6), wp_spa_json_get_size (v6), |
| 157 |
"[true]", 6); |
| 158 |
} |
| 159 |
|
| 160 |
{ |
| 161 |
gboolean v2 = FALSE; |
| 162 |
gint32 v3 = 0; |
| 163 |
float v4 = 0.0f; |
| 164 |
g_autofree gchar *v5 = NULL; |
| 165 |
g_autoptr (WpSpaJson) v6 = NULL; |
| 166 |
g_assert_true (wp_spa_json_object_get (json, |
| 167 |
"key6", "J", &v6, |
| 168 |
"key3", "i", &v3, |
| 169 |
"key5", "s", &v5, |
| 170 |
"key1", "n", |
| 171 |
"key2", "b", &v2, |
| 172 |
"key4", "f", &v4, |
| 173 |
NULL)); |
| 174 |
g_assert_true (v2); |
| 175 |
g_assert_cmpint (v3, ==, 3); |
| 176 |
g_assert_cmpfloat_with_epsilon (v4, 2.72f, 0.001f); |
| 177 |
g_assert_cmpstr (v5, ==, "str"); |
| 178 |
g_assert_nonnull (v6); |
| 179 |
g_assert_cmpmem (wp_spa_json_get_data (v6), wp_spa_json_get_size (v6), |
| 180 |
"[true]", 6); |
| 181 |
} |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
static void |
| 186 |
test_spa_json_array_builder_parser_iterator (void) |
| 187 |
{ |
| 188 |
g_autoptr (WpSpaJson) json = NULL; |
| 189 |
|
| 190 |
{ |
| 191 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_array (); |
| 192 |
g_assert_nonnull (b); |
| 193 |
wp_spa_json_builder_add_int (b, 1); |
| 194 |
wp_spa_json_builder_add_int (b, 2); |
| 195 |
wp_spa_json_builder_add_int (b, 3); |
| 196 |
json = wp_spa_json_builder_end (b); |
| 197 |
} |
| 198 |
|
| 199 |
g_assert_true (wp_spa_json_is_array (json)); |
| 200 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 201 |
"[1, 2, 3]", 9); |
| 202 |
|
| 203 |
{ |
| 204 |
g_autoptr (WpSpaJsonParser) p = wp_spa_json_parser_new_array (json); |
| 205 |
g_assert_nonnull (p); |
| 206 |
gint32 v = 0; |
| 207 |
g_assert_true (wp_spa_json_parser_get_int (p, &v)); |
| 208 |
g_assert_cmpint (v, ==, 1); |
| 209 |
g_assert_true (wp_spa_json_parser_get_int (p, &v)); |
| 210 |
g_assert_cmpint (v, ==, 2); |
| 211 |
g_assert_true (wp_spa_json_parser_get_int (p, &v)); |
| 212 |
g_assert_cmpint (v, ==, 3); |
| 213 |
wp_spa_json_parser_end (p); |
| 214 |
g_assert_false (wp_spa_json_parser_get_null (p)); |
| 215 |
} |
| 216 |
|
| 217 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 218 |
g_assert_nonnull (it); |
| 219 |
|
| 220 |
{ |
| 221 |
GValue next = G_VALUE_INIT; |
| 222 |
g_assert_true (wp_iterator_next (it, &next)); |
| 223 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 224 |
g_assert_nonnull (j); |
| 225 |
g_assert_true (wp_spa_json_is_int (j)); |
| 226 |
gint32 v = 0; |
| 227 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 228 |
g_assert_cmpint (v, ==, 1); |
| 229 |
g_value_unset (&next); |
| 230 |
} |
| 231 |
|
| 232 |
{ |
| 233 |
GValue next = G_VALUE_INIT; |
| 234 |
g_assert_true (wp_iterator_next (it, &next)); |
| 235 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 236 |
g_assert_nonnull (j); |
| 237 |
g_assert_true (wp_spa_json_is_int (j)); |
| 238 |
gint32 v = 0; |
| 239 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 240 |
g_assert_cmpint (v, ==, 2); |
| 241 |
g_value_unset (&next); |
| 242 |
} |
| 243 |
|
| 244 |
{ |
| 245 |
GValue next = G_VALUE_INIT; |
| 246 |
g_assert_true (wp_iterator_next (it, &next)); |
| 247 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 248 |
g_assert_nonnull (j); |
| 249 |
g_assert_true (wp_spa_json_is_int (j)); |
| 250 |
gint32 v = 0; |
| 251 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 252 |
g_assert_cmpint (v, ==, 3); |
| 253 |
g_value_unset (&next); |
| 254 |
} |
| 255 |
|
| 256 |
g_assert_false (wp_iterator_next (it, NULL)); |
| 257 |
wp_iterator_reset (it); |
| 258 |
|
| 259 |
{ |
| 260 |
GValue next = G_VALUE_INIT; |
| 261 |
g_assert_true (wp_iterator_next (it, &next)); |
| 262 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 263 |
g_assert_nonnull (j); |
| 264 |
g_assert_true (wp_spa_json_is_int (j)); |
| 265 |
gint32 v = 0; |
| 266 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 267 |
g_assert_cmpint (v, ==, 1); |
| 268 |
g_value_unset (&next); |
| 269 |
} |
| 270 |
} |
| 271 |
|
| 272 |
static void |
| 273 |
test_spa_json_object_builder_parser_iterator (void) |
| 274 |
{ |
| 275 |
g_autoptr (WpSpaJson) json = NULL; |
| 276 |
|
| 277 |
{ |
| 278 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_object (); |
| 279 |
g_assert_nonnull (b); |
| 280 |
wp_spa_json_builder_add_property (b, "key-null"); |
| 281 |
wp_spa_json_builder_add_null (b); |
| 282 |
wp_spa_json_builder_add_property (b, "key-boolean"); |
| 283 |
wp_spa_json_builder_add_boolean (b, TRUE); |
| 284 |
wp_spa_json_builder_add_property (b, "key-int"); |
| 285 |
wp_spa_json_builder_add_int (b, 7); |
| 286 |
wp_spa_json_builder_add_property (b, "key-float"); |
| 287 |
wp_spa_json_builder_add_float (b, 0.12f); |
| 288 |
wp_spa_json_builder_add_property (b, "key-string"); |
| 289 |
wp_spa_json_builder_add_string (b, "str"); |
| 290 |
wp_spa_json_builder_add_property (b, "key-empty-string"); |
| 291 |
wp_spa_json_builder_add_string (b, ""); |
| 292 |
wp_spa_json_builder_add_property (b, "key-special-char-string"); |
| 293 |
wp_spa_json_builder_add_string (b, "\v\v\v\v"); |
| 294 |
json = wp_spa_json_builder_end (b); |
| 295 |
} |
| 296 |
|
| 297 |
g_assert_true (wp_spa_json_is_object (json)); |
| 298 |
|
| 299 |
{ |
| 300 |
g_autoptr (WpSpaJsonParser) p = wp_spa_json_parser_new_object (json); |
| 301 |
g_assert_nonnull (p); |
| 302 |
|
| 303 |
g_autofree gchar *key_null = wp_spa_json_parser_get_string (p); |
| 304 |
g_assert_nonnull (key_null); |
| 305 |
g_assert_cmpstr (key_null, ==, "key-null"); |
| 306 |
g_assert_true (wp_spa_json_parser_get_null (p)); |
| 307 |
|
| 308 |
g_autofree gchar *key_boolean = wp_spa_json_parser_get_string (p); |
| 309 |
g_assert_nonnull (key_boolean); |
| 310 |
g_assert_cmpstr (key_boolean, ==, "key-boolean"); |
| 311 |
gboolean v_boolean = FALSE; |
| 312 |
g_assert_true (wp_spa_json_parser_get_boolean (p, &v_boolean)); |
| 313 |
g_assert_true (v_boolean); |
| 314 |
|
| 315 |
g_autofree gchar *key_int = wp_spa_json_parser_get_string (p); |
| 316 |
g_assert_nonnull (key_int); |
| 317 |
g_assert_cmpstr (key_int, ==, "key-int"); |
| 318 |
gint32 v_int = 0; |
| 319 |
g_assert_true (wp_spa_json_parser_get_int (p, &v_int)); |
| 320 |
g_assert_cmpint (v_int, ==, 7); |
| 321 |
|
| 322 |
g_autofree gchar *key_float = wp_spa_json_parser_get_string (p); |
| 323 |
g_assert_nonnull (key_float); |
| 324 |
g_assert_cmpstr (key_float, ==, "key-float"); |
| 325 |
float v_float = 0.0f; |
| 326 |
g_assert_true (wp_spa_json_parser_get_float (p, &v_float)); |
| 327 |
g_assert_cmpfloat_with_epsilon (v_float, 0.12f, 0.001f); |
| 328 |
|
| 329 |
g_autofree gchar *key_string = wp_spa_json_parser_get_string (p); |
| 330 |
g_assert_nonnull (key_string); |
| 331 |
g_assert_cmpstr (key_string, ==, "key-string"); |
| 332 |
g_autofree gchar *v_string = wp_spa_json_parser_get_string (p); |
| 333 |
g_assert_nonnull (v_string); |
| 334 |
g_assert_cmpstr (v_string, ==, "str"); |
| 335 |
|
| 336 |
g_autofree gchar *key_empty_string = wp_spa_json_parser_get_string (p); |
| 337 |
g_assert_nonnull (key_empty_string); |
| 338 |
g_assert_cmpstr (key_empty_string, ==, "key-empty-string"); |
| 339 |
g_autofree gchar *v_empty_string = wp_spa_json_parser_get_string (p); |
| 340 |
g_assert_nonnull (v_empty_string); |
| 341 |
g_assert_cmpstr (v_empty_string, ==, ""); |
| 342 |
|
| 343 |
g_autofree gchar *key_special_char_string = wp_spa_json_parser_get_string (p); |
| 344 |
g_assert_nonnull (key_special_char_string); |
| 345 |
g_assert_cmpstr (key_special_char_string, ==, "key-special-char-string"); |
| 346 |
g_autofree gchar *v_special_char_string = wp_spa_json_parser_get_string (p); |
| 347 |
g_assert_nonnull (v_special_char_string); |
| 348 |
g_assert_cmpstr (v_special_char_string, ==, "\v\v\v\v"); |
| 349 |
|
| 350 |
wp_spa_json_parser_end (p); |
| 351 |
g_assert_false (wp_spa_json_parser_get_null (p)); |
| 352 |
} |
| 353 |
|
| 354 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 355 |
g_assert_nonnull (it); |
| 356 |
|
| 357 |
{ |
| 358 |
GValue next = G_VALUE_INIT; |
| 359 |
g_assert_true (wp_iterator_next (it, &next)); |
| 360 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 361 |
g_assert_nonnull (j); |
| 362 |
g_assert_true (wp_spa_json_is_string (j)); |
| 363 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 364 |
g_assert_nonnull (v); |
| 365 |
g_assert_cmpstr (v, ==, "key-null"); |
| 366 |
g_value_unset (&next); |
| 367 |
} |
| 368 |
|
| 369 |
{ |
| 370 |
GValue next = G_VALUE_INIT; |
| 371 |
g_assert_true (wp_iterator_next (it, &next)); |
| 372 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 373 |
g_assert_nonnull (j); |
| 374 |
g_assert_true (wp_spa_json_is_null (j)); |
| 375 |
g_value_unset (&next); |
| 376 |
} |
| 377 |
|
| 378 |
{ |
| 379 |
GValue next = G_VALUE_INIT; |
| 380 |
g_assert_true (wp_iterator_next (it, &next)); |
| 381 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 382 |
g_assert_nonnull (j); |
| 383 |
g_assert_true (wp_spa_json_is_string (j)); |
| 384 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 385 |
g_assert_nonnull (v); |
| 386 |
g_assert_cmpstr (v, ==, "key-boolean"); |
| 387 |
g_value_unset (&next); |
| 388 |
} |
| 389 |
|
| 390 |
{ |
| 391 |
GValue next = G_VALUE_INIT; |
| 392 |
g_assert_true (wp_iterator_next (it, &next)); |
| 393 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 394 |
g_assert_nonnull (j); |
| 395 |
g_assert_true (wp_spa_json_is_boolean (j)); |
| 396 |
gboolean v = FALSE; |
| 397 |
g_assert_true (wp_spa_json_parse_boolean (j, &v)); |
| 398 |
g_assert_true (v); |
| 399 |
g_value_unset (&next); |
| 400 |
} |
| 401 |
|
| 402 |
{ |
| 403 |
GValue next = G_VALUE_INIT; |
| 404 |
g_assert_true (wp_iterator_next (it, &next)); |
| 405 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 406 |
g_assert_nonnull (j); |
| 407 |
g_assert_true (wp_spa_json_is_string (j)); |
| 408 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 409 |
g_assert_nonnull (v); |
| 410 |
g_assert_cmpstr (v, ==, "key-int"); |
| 411 |
g_value_unset (&next); |
| 412 |
} |
| 413 |
|
| 414 |
{ |
| 415 |
GValue next = G_VALUE_INIT; |
| 416 |
g_assert_true (wp_iterator_next (it, &next)); |
| 417 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 418 |
g_assert_nonnull (j); |
| 419 |
g_assert_true (wp_spa_json_is_int (j)); |
| 420 |
gint32 v = 0; |
| 421 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 422 |
g_assert_cmpint (v, ==, 7); |
| 423 |
g_value_unset (&next); |
| 424 |
} |
| 425 |
|
| 426 |
{ |
| 427 |
GValue next = G_VALUE_INIT; |
| 428 |
g_assert_true (wp_iterator_next (it, &next)); |
| 429 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 430 |
g_assert_nonnull (j); |
| 431 |
g_assert_true (wp_spa_json_is_string (j)); |
| 432 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 433 |
g_assert_nonnull (v); |
| 434 |
g_assert_cmpstr (v, ==, "key-float"); |
| 435 |
g_value_unset (&next); |
| 436 |
} |
| 437 |
|
| 438 |
{ |
| 439 |
GValue next = G_VALUE_INIT; |
| 440 |
g_assert_true (wp_iterator_next (it, &next)); |
| 441 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 442 |
g_assert_nonnull (j); |
| 443 |
g_assert_true (wp_spa_json_is_float (j)); |
| 444 |
float v = 0; |
| 445 |
g_assert_true (wp_spa_json_parse_float (j, &v)); |
| 446 |
g_assert_cmpfloat_with_epsilon (v, 0.12f, 0.001f); |
| 447 |
g_value_unset (&next); |
| 448 |
} |
| 449 |
|
| 450 |
{ |
| 451 |
GValue next = G_VALUE_INIT; |
| 452 |
g_assert_true (wp_iterator_next (it, &next)); |
| 453 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 454 |
g_assert_nonnull (j); |
| 455 |
g_assert_true (wp_spa_json_is_string (j)); |
| 456 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 457 |
g_assert_nonnull (v); |
| 458 |
g_assert_cmpstr (v, ==, "key-string"); |
| 459 |
g_value_unset (&next); |
| 460 |
} |
| 461 |
|
| 462 |
{ |
| 463 |
GValue next = G_VALUE_INIT; |
| 464 |
g_assert_true (wp_iterator_next (it, &next)); |
| 465 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 466 |
g_assert_nonnull (j); |
| 467 |
g_assert_true (wp_spa_json_is_string (j)); |
| 468 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 469 |
g_assert_nonnull (v); |
| 470 |
g_assert_cmpstr (v, ==, "str"); |
| 471 |
g_value_unset (&next); |
| 472 |
} |
| 473 |
|
| 474 |
{ |
| 475 |
GValue next = G_VALUE_INIT; |
| 476 |
g_assert_true (wp_iterator_next (it, &next)); |
| 477 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 478 |
g_assert_nonnull (j); |
| 479 |
g_assert_true (wp_spa_json_is_string (j)); |
| 480 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 481 |
g_assert_nonnull (v); |
| 482 |
g_assert_cmpstr (v, ==, "key-empty-string"); |
| 483 |
g_value_unset (&next); |
| 484 |
} |
| 485 |
|
| 486 |
{ |
| 487 |
GValue next = G_VALUE_INIT; |
| 488 |
g_assert_true (wp_iterator_next (it, &next)); |
| 489 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 490 |
g_assert_nonnull (j); |
| 491 |
g_assert_true (wp_spa_json_is_string (j)); |
| 492 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 493 |
g_assert_nonnull (v); |
| 494 |
g_assert_cmpstr (v, ==, ""); |
| 495 |
g_value_unset (&next); |
| 496 |
} |
| 497 |
|
| 498 |
{ |
| 499 |
GValue next = G_VALUE_INIT; |
| 500 |
g_assert_true (wp_iterator_next (it, &next)); |
| 501 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 502 |
g_assert_nonnull (j); |
| 503 |
g_assert_true (wp_spa_json_is_string (j)); |
| 504 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 505 |
g_assert_nonnull (v); |
| 506 |
g_assert_cmpstr (v, ==, "key-special-char-string"); |
| 507 |
g_value_unset (&next); |
| 508 |
} |
| 509 |
|
| 510 |
{ |
| 511 |
GValue next = G_VALUE_INIT; |
| 512 |
g_assert_true (wp_iterator_next (it, &next)); |
| 513 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 514 |
g_assert_nonnull (j); |
| 515 |
g_assert_true (wp_spa_json_is_string (j)); |
| 516 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 517 |
g_assert_nonnull (v); |
| 518 |
g_assert_cmpstr (v, ==, "\v\v\v\v"); |
| 519 |
g_value_unset (&next); |
| 520 |
} |
| 521 |
|
| 522 |
g_assert_false (wp_iterator_next (it, NULL)); |
| 523 |
wp_iterator_reset (it); |
| 524 |
|
| 525 |
{ |
| 526 |
GValue next = G_VALUE_INIT; |
| 527 |
g_assert_true (wp_iterator_next (it, &next)); |
| 528 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 529 |
g_assert_nonnull (j); |
| 530 |
g_assert_true (wp_spa_json_is_string (j)); |
| 531 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 532 |
g_assert_nonnull (v); |
| 533 |
g_assert_cmpstr (v, ==, "key-null"); |
| 534 |
g_value_unset (&next); |
| 535 |
} |
| 536 |
} |
| 537 |
|
| 538 |
static void |
| 539 |
test_spa_json_nested (void) |
| 540 |
{ |
| 541 |
g_autoptr (WpSpaJson) array = NULL; |
| 542 |
g_autoptr (WpSpaJson) array2 = NULL; |
| 543 |
g_autoptr (WpSpaJson) object = NULL; |
| 544 |
g_autoptr (WpSpaJson) json = NULL; |
| 545 |
|
| 546 |
{ |
| 547 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_array (); |
| 548 |
g_assert_nonnull (b); |
| 549 |
wp_spa_json_builder_add_int (b, 5); |
| 550 |
wp_spa_json_builder_add_int (b, 10); |
| 551 |
wp_spa_json_builder_add_int (b, 15); |
| 552 |
array = wp_spa_json_builder_end (b); |
| 553 |
} |
| 554 |
g_assert_true (wp_spa_json_is_array (array)); |
| 555 |
g_assert_cmpuint (wp_spa_json_get_size (array), ==, 11); |
| 556 |
g_assert_cmpmem (wp_spa_json_get_data (array), wp_spa_json_get_size (array), |
| 557 |
"[5, 10, 15]", 11); |
| 558 |
|
| 559 |
{ |
| 560 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_array (); |
| 561 |
g_assert_nonnull (b); |
| 562 |
wp_spa_json_builder_add_int (b, 2); |
| 563 |
wp_spa_json_builder_add_int (b, 4); |
| 564 |
array2 = wp_spa_json_builder_end (b); |
| 565 |
} |
| 566 |
g_assert_true (wp_spa_json_is_array (array2)); |
| 567 |
g_assert_cmpuint (wp_spa_json_get_size (array2), ==, 6); |
| 568 |
g_assert_cmpmem (wp_spa_json_get_data (array2), wp_spa_json_get_size (array2), |
| 569 |
"[2, 4]", 6); |
| 570 |
|
| 571 |
{ |
| 572 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_object (); |
| 573 |
g_assert_nonnull (b); |
| 574 |
wp_spa_json_builder_add_property (b, "key-boolean"); |
| 575 |
wp_spa_json_builder_add_boolean (b, FALSE); |
| 576 |
wp_spa_json_builder_add_property (b, "key-int"); |
| 577 |
wp_spa_json_builder_add_int (b, 8); |
| 578 |
wp_spa_json_builder_add_property (b, "key-array"); |
| 579 |
wp_spa_json_builder_add_json (b, array2); |
| 580 |
object = wp_spa_json_builder_end (b); |
| 581 |
} |
| 582 |
g_assert_true (wp_spa_json_is_object (object)); |
| 583 |
g_assert_cmpuint (wp_spa_json_get_size (object), ==, 54); |
| 584 |
g_assert_cmpmem (wp_spa_json_get_data (object), wp_spa_json_get_size (object), |
| 585 |
"{\"key-boolean\":false, \"key-int\":8, \"key-array\":[2, 4]}", 54); |
| 586 |
|
| 587 |
{ |
| 588 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_object (); |
| 589 |
g_assert_nonnull (b); |
| 590 |
wp_spa_json_builder_add_property (b, "key-array"); |
| 591 |
wp_spa_json_builder_add_json (b, array); |
| 592 |
wp_spa_json_builder_add_property (b, "key-object"); |
| 593 |
wp_spa_json_builder_add_json (b, object); |
| 594 |
json = wp_spa_json_builder_end (b); |
| 595 |
} |
| 596 |
g_assert_true (wp_spa_json_is_object (json)); |
| 597 |
g_assert_cmpuint (wp_spa_json_get_size (json), ==, 94); |
| 598 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 599 |
"{\"key-array\":[5, 10, 15], \"key-object\":{\"key-boolean\":false, " |
| 600 |
"\"key-int\":8, \"key-array\":[2, 4]}}", 94); |
| 601 |
g_assert_cmpstr (wp_spa_json_get_data (json), ==, |
| 602 |
"{\"key-array\":[5, 10, 15], \"key-object\":{\"key-boolean\":false, " |
| 603 |
"\"key-int\":8, \"key-array\":[2, 4]}}"); |
| 604 |
|
| 605 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 606 |
g_assert_nonnull (it); |
| 607 |
|
| 608 |
{ |
| 609 |
GValue next = G_VALUE_INIT; |
| 610 |
g_assert_true (wp_iterator_next (it, &next)); |
| 611 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 612 |
g_assert_nonnull (j); |
| 613 |
g_assert_true (wp_spa_json_is_string (j)); |
| 614 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 615 |
g_assert_nonnull (v); |
| 616 |
g_assert_cmpstr (v, ==, "key-array"); |
| 617 |
g_value_unset (&next); |
| 618 |
} |
| 619 |
|
| 620 |
{ |
| 621 |
GValue next = G_VALUE_INIT; |
| 622 |
g_assert_true (wp_iterator_next (it, &next)); |
| 623 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 624 |
g_assert_nonnull (j); |
| 625 |
g_assert_true (wp_spa_json_is_array (j)); |
| 626 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 11); |
| 627 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 628 |
"[5, 10, 15]", 11); |
| 629 |
|
| 630 |
g_autoptr (WpIterator) it2 = wp_spa_json_new_iterator (j); |
| 631 |
g_assert_nonnull (it2); |
| 632 |
|
| 633 |
{ |
| 634 |
GValue next2 = G_VALUE_INIT; |
| 635 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 636 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 637 |
g_assert_nonnull (j); |
| 638 |
g_assert_true (wp_spa_json_is_int (j)); |
| 639 |
gint32 v = 0; |
| 640 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 641 |
g_assert_cmpint (v, ==, 5); |
| 642 |
g_value_unset (&next2); |
| 643 |
} |
| 644 |
|
| 645 |
{ |
| 646 |
GValue next2 = G_VALUE_INIT; |
| 647 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 648 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 649 |
g_assert_nonnull (j); |
| 650 |
g_assert_true (wp_spa_json_is_int (j)); |
| 651 |
gint32 v = 0; |
| 652 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 653 |
g_assert_cmpint (v, ==, 10); |
| 654 |
g_value_unset (&next2); |
| 655 |
} |
| 656 |
|
| 657 |
{ |
| 658 |
GValue next2 = G_VALUE_INIT; |
| 659 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 660 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 661 |
g_assert_nonnull (j); |
| 662 |
g_assert_true (wp_spa_json_is_int (j)); |
| 663 |
gint32 v = 0; |
| 664 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 665 |
g_assert_cmpint (v, ==, 15); |
| 666 |
g_value_unset (&next2); |
| 667 |
} |
| 668 |
|
| 669 |
g_value_unset (&next); |
| 670 |
} |
| 671 |
|
| 672 |
{ |
| 673 |
GValue next = G_VALUE_INIT; |
| 674 |
g_assert_true (wp_iterator_next (it, &next)); |
| 675 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 676 |
g_assert_nonnull (j); |
| 677 |
g_assert_true (wp_spa_json_is_string (j)); |
| 678 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 679 |
g_assert_nonnull (v); |
| 680 |
g_assert_cmpstr (v, ==, "key-object"); |
| 681 |
g_value_unset (&next); |
| 682 |
} |
| 683 |
|
| 684 |
{ |
| 685 |
GValue next = G_VALUE_INIT; |
| 686 |
g_assert_true (wp_iterator_next (it, &next)); |
| 687 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 688 |
g_assert_nonnull (j); |
| 689 |
g_assert_true (wp_spa_json_is_object (j)); |
| 690 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 54); |
| 691 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 692 |
"{\"key-boolean\":false, \"key-int\":8, \"key-array\":[2, 4]}", 54); |
| 693 |
|
| 694 |
g_autoptr (WpIterator) it2 = wp_spa_json_new_iterator (j); |
| 695 |
g_assert_nonnull (it2); |
| 696 |
|
| 697 |
{ |
| 698 |
GValue next2 = G_VALUE_INIT; |
| 699 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 700 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 701 |
g_assert_nonnull (j); |
| 702 |
g_assert_true (wp_spa_json_is_string (j)); |
| 703 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 704 |
g_assert_nonnull (v); |
| 705 |
g_assert_cmpstr (v, ==, "key-boolean"); |
| 706 |
g_value_unset (&next2); |
| 707 |
} |
| 708 |
|
| 709 |
{ |
| 710 |
GValue next2 = G_VALUE_INIT; |
| 711 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 712 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 713 |
g_assert_nonnull (j); |
| 714 |
g_assert_true (wp_spa_json_is_boolean (j)); |
| 715 |
gboolean v = TRUE; |
| 716 |
g_assert_true (wp_spa_json_parse_boolean (j, &v)); |
| 717 |
g_assert_false (v); |
| 718 |
g_value_unset (&next2); |
| 719 |
} |
| 720 |
|
| 721 |
{ |
| 722 |
GValue next2 = G_VALUE_INIT; |
| 723 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 724 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 725 |
g_assert_nonnull (j); |
| 726 |
g_assert_true (wp_spa_json_is_string (j)); |
| 727 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 728 |
g_assert_nonnull (v); |
| 729 |
g_assert_cmpstr (v, ==, "key-int"); |
| 730 |
g_value_unset (&next2); |
| 731 |
} |
| 732 |
|
| 733 |
{ |
| 734 |
GValue next2 = G_VALUE_INIT; |
| 735 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 736 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 737 |
g_assert_nonnull (j); |
| 738 |
g_assert_true (wp_spa_json_is_int (j)); |
| 739 |
gint32 v = 0; |
| 740 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 741 |
g_assert_cmpint (v, ==, 8); |
| 742 |
g_value_unset (&next2); |
| 743 |
} |
| 744 |
|
| 745 |
{ |
| 746 |
GValue next2 = G_VALUE_INIT; |
| 747 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 748 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 749 |
g_assert_nonnull (j); |
| 750 |
g_assert_true (wp_spa_json_is_string (j)); |
| 751 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 752 |
g_assert_nonnull (v); |
| 753 |
g_assert_cmpstr (v, ==, "key-array"); |
| 754 |
g_value_unset (&next2); |
| 755 |
} |
| 756 |
|
| 757 |
{ |
| 758 |
GValue next2 = G_VALUE_INIT; |
| 759 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 760 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 761 |
g_assert_nonnull (j); |
| 762 |
g_assert_true (wp_spa_json_is_array (array2)); |
| 763 |
g_assert_cmpuint (wp_spa_json_get_size (array2), ==, 6); |
| 764 |
g_assert_cmpmem (wp_spa_json_get_data (array2), |
| 765 |
wp_spa_json_get_size (array2), "[2, 4]", 6); |
| 766 |
|
| 767 |
g_autoptr (WpIterator) it3 = wp_spa_json_new_iterator (j); |
| 768 |
g_assert_nonnull (it3); |
| 769 |
|
| 770 |
{ |
| 771 |
GValue next3 = G_VALUE_INIT; |
| 772 |
g_assert_true (wp_iterator_next (it3, &next3)); |
| 773 |
WpSpaJson *j = g_value_get_boxed (&next3); |
| 774 |
g_assert_nonnull (j); |
| 775 |
g_assert_true (wp_spa_json_is_int (j)); |
| 776 |
gint32 v = 0; |
| 777 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 778 |
g_assert_cmpint (v, ==, 2); |
| 779 |
g_value_unset (&next3); |
| 780 |
} |
| 781 |
|
| 782 |
{ |
| 783 |
GValue next3 = G_VALUE_INIT; |
| 784 |
g_assert_true (wp_iterator_next (it3, &next3)); |
| 785 |
WpSpaJson *j = g_value_get_boxed (&next3); |
| 786 |
g_assert_nonnull (j); |
| 787 |
g_assert_true (wp_spa_json_is_int (j)); |
| 788 |
gint32 v = 0; |
| 789 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 790 |
g_assert_cmpint (v, ==, 4); |
| 791 |
g_value_unset (&next3); |
| 792 |
} |
| 793 |
|
| 794 |
g_value_unset (&next2); |
| 795 |
} |
| 796 |
|
| 797 |
g_value_unset (&next); |
| 798 |
} |
| 799 |
|
| 800 |
g_assert_false (wp_iterator_next (it, NULL)); |
| 801 |
wp_iterator_reset (it); |
| 802 |
|
| 803 |
{ |
| 804 |
GValue next = G_VALUE_INIT; |
| 805 |
g_assert_true (wp_iterator_next (it, &next)); |
| 806 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 807 |
g_assert_nonnull (j); |
| 808 |
g_assert_true (wp_spa_json_is_string (j)); |
| 809 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 810 |
g_assert_nonnull (v); |
| 811 |
g_assert_cmpstr (v, ==, "key-array"); |
| 812 |
g_value_unset (&next); |
| 813 |
} |
| 814 |
} |
| 815 |
|
| 816 |
static void |
| 817 |
test_spa_json_nested2 (void) |
| 818 |
{ |
| 819 |
const gchar json_str[] = "[[[[1], [2]], [3]], [4]]"; |
| 820 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_wrap_string (json_str); |
| 821 |
|
| 822 |
g_assert_true (wp_spa_json_is_array (json)); |
| 823 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 824 |
"[[[[1], [2]], [3]], [4]]", 24); |
| 825 |
|
| 826 |
{ |
| 827 |
g_autoptr (WpSpaJsonParser) p = wp_spa_json_parser_new_array (json); |
| 828 |
g_assert_nonnull (p); |
| 829 |
g_autoptr (WpSpaJson) j0 = wp_spa_json_parser_get_json (p); |
| 830 |
g_assert_nonnull (j0); |
| 831 |
g_assert_cmpmem (wp_spa_json_get_data (j0), wp_spa_json_get_size (j0), |
| 832 |
"[[[1], [2]], [3]]", 17); |
| 833 |
g_autoptr (WpSpaJson) j1 = wp_spa_json_parser_get_json (p); |
| 834 |
g_assert_nonnull (j1); |
| 835 |
g_assert_cmpmem (wp_spa_json_get_data (j1), wp_spa_json_get_size (j1), |
| 836 |
"[4]", 3); |
| 837 |
wp_spa_json_parser_end (p); |
| 838 |
g_assert_false (wp_spa_json_parser_get_null (p)); |
| 839 |
} |
| 840 |
|
| 841 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 842 |
g_assert_nonnull (it); |
| 843 |
|
| 844 |
{ |
| 845 |
GValue next = G_VALUE_INIT; |
| 846 |
g_assert_true (wp_iterator_next (it, &next)); |
| 847 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 848 |
g_assert_nonnull (j); |
| 849 |
g_assert_true (wp_spa_json_is_array (j)); |
| 850 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 17); |
| 851 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 852 |
"[[[1], [2]], [3]]", 17); |
| 853 |
|
| 854 |
g_autoptr (WpIterator) it2 = wp_spa_json_new_iterator (j); |
| 855 |
g_assert_nonnull (it2); |
| 856 |
|
| 857 |
{ |
| 858 |
GValue next2 = G_VALUE_INIT; |
| 859 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 860 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 861 |
g_assert_nonnull (j); |
| 862 |
g_assert_true (wp_spa_json_is_array (j)); |
| 863 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 10); |
| 864 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 865 |
"[[1], [2]]", 10); |
| 866 |
|
| 867 |
g_autoptr (WpIterator) it3 = wp_spa_json_new_iterator (j); |
| 868 |
g_assert_nonnull (it3); |
| 869 |
|
| 870 |
{ |
| 871 |
GValue next3 = G_VALUE_INIT; |
| 872 |
g_assert_true (wp_iterator_next (it3, &next3)); |
| 873 |
WpSpaJson *j = g_value_get_boxed (&next3); |
| 874 |
g_assert_nonnull (j); |
| 875 |
g_assert_true (wp_spa_json_is_array (j)); |
| 876 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 3); |
| 877 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 878 |
"[1]", 3); |
| 879 |
|
| 880 |
g_autoptr (WpIterator) it4 = wp_spa_json_new_iterator (j); |
| 881 |
g_assert_nonnull (it4); |
| 882 |
|
| 883 |
{ |
| 884 |
GValue next4 = G_VALUE_INIT; |
| 885 |
g_assert_true (wp_iterator_next (it4, &next4)); |
| 886 |
WpSpaJson *j = g_value_get_boxed (&next4); |
| 887 |
g_assert_nonnull (j); |
| 888 |
g_assert_true (wp_spa_json_is_int (j)); |
| 889 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 890 |
"1", 1); |
| 891 |
g_value_unset (&next4); |
| 892 |
} |
| 893 |
|
| 894 |
g_value_unset (&next3); |
| 895 |
} |
| 896 |
|
| 897 |
{ |
| 898 |
GValue next3 = G_VALUE_INIT; |
| 899 |
g_assert_true (wp_iterator_next (it3, &next3)); |
| 900 |
WpSpaJson *j = g_value_get_boxed (&next3); |
| 901 |
g_assert_nonnull (j); |
| 902 |
g_assert_true (wp_spa_json_is_array (j)); |
| 903 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 3); |
| 904 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 905 |
"[2]", 3); |
| 906 |
|
| 907 |
g_autoptr (WpIterator) it4 = wp_spa_json_new_iterator (j); |
| 908 |
g_assert_nonnull (it4); |
| 909 |
|
| 910 |
{ |
| 911 |
GValue next4 = G_VALUE_INIT; |
| 912 |
g_assert_true (wp_iterator_next (it4, &next4)); |
| 913 |
WpSpaJson *j = g_value_get_boxed (&next4); |
| 914 |
g_assert_nonnull (j); |
| 915 |
g_assert_true (wp_spa_json_is_int (j)); |
| 916 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 917 |
"2", 1); |
| 918 |
g_value_unset (&next4); |
| 919 |
} |
| 920 |
|
| 921 |
g_value_unset (&next3); |
| 922 |
} |
| 923 |
|
| 924 |
g_value_unset (&next2); |
| 925 |
} |
| 926 |
|
| 927 |
{ |
| 928 |
GValue next2 = G_VALUE_INIT; |
| 929 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 930 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 931 |
g_assert_nonnull (j); |
| 932 |
g_assert_true (wp_spa_json_is_array (j)); |
| 933 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 3); |
| 934 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 935 |
"[3]", 3); |
| 936 |
|
| 937 |
g_autoptr (WpIterator) it3 = wp_spa_json_new_iterator (j); |
| 938 |
g_assert_nonnull (it3); |
| 939 |
|
| 940 |
{ |
| 941 |
GValue next3 = G_VALUE_INIT; |
| 942 |
g_assert_true (wp_iterator_next (it3, &next3)); |
| 943 |
WpSpaJson *j = g_value_get_boxed (&next3); |
| 944 |
g_assert_nonnull (j); |
| 945 |
g_assert_true (wp_spa_json_is_int (j)); |
| 946 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 947 |
"3", 1); |
| 948 |
g_value_unset (&next3); |
| 949 |
} |
| 950 |
|
| 951 |
g_value_unset (&next2); |
| 952 |
} |
| 953 |
|
| 954 |
g_value_unset (&next); |
| 955 |
} |
| 956 |
|
| 957 |
{ |
| 958 |
GValue next = G_VALUE_INIT; |
| 959 |
g_assert_true (wp_iterator_next (it, &next)); |
| 960 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 961 |
g_assert_nonnull (j); |
| 962 |
g_assert_true (wp_spa_json_is_array (j)); |
| 963 |
g_assert_cmpuint (wp_spa_json_get_size (j), ==, 3); |
| 964 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 965 |
"[4]", 3); |
| 966 |
|
| 967 |
g_autoptr (WpIterator) it2 = wp_spa_json_new_iterator (j); |
| 968 |
g_assert_nonnull (it2); |
| 969 |
|
| 970 |
{ |
| 971 |
GValue next2 = G_VALUE_INIT; |
| 972 |
g_assert_true (wp_iterator_next (it2, &next2)); |
| 973 |
WpSpaJson *j = g_value_get_boxed (&next2); |
| 974 |
g_assert_nonnull (j); |
| 975 |
g_assert_true (wp_spa_json_is_int (j)); |
| 976 |
g_assert_cmpmem (wp_spa_json_get_data (j), wp_spa_json_get_size (j), |
| 977 |
"4", 1); |
| 978 |
g_value_unset (&next2); |
| 979 |
} |
| 980 |
|
| 981 |
g_value_unset (&next); |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
static void |
| 986 |
test_spa_json_nested3 (void) |
| 987 |
{ |
| 988 |
const gchar json_str[] = |
| 989 |
"{ test-setting-json3: { key1: \"value\", key2: 2, key3: true } }"; |
| 990 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_wrap_string (json_str); |
| 991 |
g_assert_nonnull (json); |
| 992 |
g_assert_true (wp_spa_json_is_object (json)); |
| 993 |
|
| 994 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 995 |
g_assert_nonnull (it); |
| 996 |
|
| 997 |
{ |
| 998 |
GValue next = G_VALUE_INIT; |
| 999 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1000 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1001 |
g_assert_nonnull (j); |
| 1002 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1003 |
g_assert_cmpstr (v, ==, "test-setting-json3"); |
| 1004 |
g_value_unset (&next); |
| 1005 |
} |
| 1006 |
|
| 1007 |
{ |
| 1008 |
GValue next = G_VALUE_INIT; |
| 1009 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1010 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1011 |
g_assert_nonnull (j); |
| 1012 |
g_assert_true (wp_spa_json_is_object (j)); |
| 1013 |
g_autofree gchar *v = wp_spa_json_to_string (j); |
| 1014 |
g_assert_cmpstr (v, ==, "{ key1: \"value\", key2: 2, key3: true }"); |
| 1015 |
g_value_unset (&next); |
| 1016 |
} |
| 1017 |
} |
| 1018 |
|
| 1019 |
static void |
| 1020 |
test_spa_json_ownership (void) |
| 1021 |
{ |
| 1022 |
g_autoptr (WpSpaJson) json = NULL; |
| 1023 |
|
| 1024 |
{ |
| 1025 |
const gchar json_str[] = "{\"name\":\"John\", \"age\":30, \"car\":null}"; |
| 1026 |
json = wp_spa_json_new_wrap_string (json_str); |
| 1027 |
g_assert_nonnull (json); |
| 1028 |
|
| 1029 |
g_assert_false (wp_spa_json_is_unique_owner (json)); |
| 1030 |
|
| 1031 |
g_assert_true (wp_spa_json_is_object (json)); |
| 1032 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 1033 |
"{\"name\":\"John\", \"age\":30, \"car\":null}", 37); |
| 1034 |
|
| 1035 |
json = wp_spa_json_ensure_unique_owner (json); |
| 1036 |
g_assert_nonnull (json); |
| 1037 |
g_assert_true (wp_spa_json_is_unique_owner (json)); |
| 1038 |
} |
| 1039 |
|
| 1040 |
g_assert_true (wp_spa_json_is_object (json)); |
| 1041 |
g_assert_cmpmem (wp_spa_json_get_data (json), wp_spa_json_get_size (json), |
| 1042 |
"{\"name\":\"John\", \"age\":30, \"car\":null}", 37); |
| 1043 |
|
| 1044 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 1045 |
g_assert_nonnull (it); |
| 1046 |
|
| 1047 |
{ |
| 1048 |
GValue next = G_VALUE_INIT; |
| 1049 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1050 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1051 |
g_assert_nonnull (j); |
| 1052 |
g_assert_true (wp_spa_json_is_string (j)); |
| 1053 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1054 |
g_assert_nonnull (v); |
| 1055 |
g_assert_cmpstr (v, ==, "name"); |
| 1056 |
g_value_unset (&next); |
| 1057 |
} |
| 1058 |
|
| 1059 |
{ |
| 1060 |
GValue next = G_VALUE_INIT; |
| 1061 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1062 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1063 |
g_assert_nonnull (j); |
| 1064 |
g_assert_true (wp_spa_json_is_string (j)); |
| 1065 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1066 |
g_assert_nonnull (v); |
| 1067 |
g_assert_cmpstr (v, ==, "John"); |
| 1068 |
g_value_unset (&next); |
| 1069 |
} |
| 1070 |
|
| 1071 |
{ |
| 1072 |
GValue next = G_VALUE_INIT; |
| 1073 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1074 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1075 |
g_assert_nonnull (j); |
| 1076 |
g_assert_true (wp_spa_json_is_string (j)); |
| 1077 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1078 |
g_assert_nonnull (v); |
| 1079 |
g_assert_cmpstr (v, ==, "age"); |
| 1080 |
g_value_unset (&next); |
| 1081 |
} |
| 1082 |
|
| 1083 |
{ |
| 1084 |
GValue next = G_VALUE_INIT; |
| 1085 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1086 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1087 |
g_assert_nonnull (j); |
| 1088 |
g_assert_true (wp_spa_json_is_int (j)); |
| 1089 |
gint32 v = 0; |
| 1090 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 1091 |
g_assert_cmpint (v, ==, 30); |
| 1092 |
g_value_unset (&next); |
| 1093 |
} |
| 1094 |
|
| 1095 |
{ |
| 1096 |
GValue next = G_VALUE_INIT; |
| 1097 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1098 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1099 |
g_assert_nonnull (j); |
| 1100 |
g_assert_true (wp_spa_json_is_string (j)); |
| 1101 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1102 |
g_assert_nonnull (v); |
| 1103 |
g_assert_cmpstr (v, ==, "car"); |
| 1104 |
g_value_unset (&next); |
| 1105 |
} |
| 1106 |
|
| 1107 |
{ |
| 1108 |
GValue next = G_VALUE_INIT; |
| 1109 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1110 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1111 |
g_assert_nonnull (j); |
| 1112 |
g_assert_true (wp_spa_json_is_null (j)); |
| 1113 |
g_value_unset (&next); |
| 1114 |
} |
| 1115 |
} |
| 1116 |
|
| 1117 |
static void |
| 1118 |
test_spa_json_spa_format (void) |
| 1119 |
{ |
| 1120 |
g_autoptr (WpSpaJson) json = NULL; |
| 1121 |
|
| 1122 |
const gchar json_str[] = "{ name = John age:30, \"car\" null }"; |
| 1123 |
json = wp_spa_json_new_wrap_string (json_str); |
| 1124 |
g_assert_nonnull (json); |
| 1125 |
|
| 1126 |
g_assert_true (wp_spa_json_is_object (json)); |
| 1127 |
|
| 1128 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 1129 |
g_assert_nonnull (it); |
| 1130 |
|
| 1131 |
{ |
| 1132 |
GValue next = G_VALUE_INIT; |
| 1133 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1134 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1135 |
g_assert_nonnull (j); |
| 1136 |
g_assert_false (wp_spa_json_is_string (j)); // FALSE because no quotes |
| 1137 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1138 |
g_assert_nonnull (v); |
| 1139 |
g_assert_cmpstr (v, ==, "name"); |
| 1140 |
g_value_unset (&next); |
| 1141 |
} |
| 1142 |
|
| 1143 |
{ |
| 1144 |
GValue next = G_VALUE_INIT; |
| 1145 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1146 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1147 |
g_assert_nonnull (j); |
| 1148 |
g_assert_false (wp_spa_json_is_string (j)); // FALSE because no quotes |
| 1149 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1150 |
g_assert_nonnull (v); |
| 1151 |
g_assert_cmpstr (v, ==, "John"); |
| 1152 |
g_value_unset (&next); |
| 1153 |
} |
| 1154 |
|
| 1155 |
{ |
| 1156 |
GValue next = G_VALUE_INIT; |
| 1157 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1158 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1159 |
g_assert_nonnull (j); |
| 1160 |
g_assert_false (wp_spa_json_is_string (j)); // FALSE because no quotes |
| 1161 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1162 |
g_assert_nonnull (v); |
| 1163 |
g_assert_cmpstr (v, ==, "age"); |
| 1164 |
g_value_unset (&next); |
| 1165 |
} |
| 1166 |
|
| 1167 |
{ |
| 1168 |
GValue next = G_VALUE_INIT; |
| 1169 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1170 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1171 |
g_assert_nonnull (j); |
| 1172 |
g_assert_true (wp_spa_json_is_int (j)); |
| 1173 |
gint32 v = 0; |
| 1174 |
g_assert_true (wp_spa_json_parse_int (j, &v)); |
| 1175 |
g_assert_cmpint (v, ==, 30); |
| 1176 |
g_value_unset (&next); |
| 1177 |
} |
| 1178 |
|
| 1179 |
{ |
| 1180 |
GValue next = G_VALUE_INIT; |
| 1181 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1182 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1183 |
g_assert_nonnull (j); |
| 1184 |
g_assert_true (wp_spa_json_is_string (j)); |
| 1185 |
g_autofree gchar *v = wp_spa_json_parse_string (j); |
| 1186 |
g_assert_nonnull (v); |
| 1187 |
g_assert_cmpstr (v, ==, "car"); |
| 1188 |
g_value_unset (&next); |
| 1189 |
} |
| 1190 |
|
| 1191 |
{ |
| 1192 |
GValue next = G_VALUE_INIT; |
| 1193 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1194 |
WpSpaJson *j = g_value_get_boxed (&next); |
| 1195 |
g_assert_nonnull (j); |
| 1196 |
g_assert_true (wp_spa_json_is_null (j)); |
| 1197 |
g_value_unset (&next); |
| 1198 |
} |
| 1199 |
} |
| 1200 |
|
| 1201 |
static void |
| 1202 |
test_spa_json_to_string (void) |
| 1203 |
{ |
| 1204 |
const gchar json_str[] = "[{\"key0\":\"val0\"}, {\"key1\":\"val1\"}]"; |
| 1205 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_wrap_string (json_str); |
| 1206 |
g_assert_nonnull (json); |
| 1207 |
|
| 1208 |
{ |
| 1209 |
g_autofree gchar *str = wp_spa_json_to_string (json); |
| 1210 |
g_assert_cmpstr (str, ==, wp_spa_json_get_data (json)); |
| 1211 |
g_assert_cmpstr (str, ==, json_str); |
| 1212 |
} |
| 1213 |
|
| 1214 |
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json); |
| 1215 |
g_assert_nonnull (it); |
| 1216 |
|
| 1217 |
{ |
| 1218 |
GValue next = G_VALUE_INIT; |
| 1219 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1220 |
WpSpaJson *o = g_value_get_boxed (&next); |
| 1221 |
g_assert_nonnull (o); |
| 1222 |
g_assert_true (wp_spa_json_is_object (o)); |
| 1223 |
g_autofree gchar *str = wp_spa_json_to_string (o); |
| 1224 |
g_assert_cmpstr (str, ==, "{\"key0\":\"val0\"}"); |
| 1225 |
g_assert_cmpstr (str, !=, wp_spa_json_get_data (o)); |
| 1226 |
|
| 1227 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_array (); |
| 1228 |
wp_spa_json_builder_add_json (b, o); |
| 1229 |
g_autoptr (WpSpaJson) json2 = wp_spa_json_builder_end (b); |
| 1230 |
g_autofree gchar *str2 = wp_spa_json_to_string (json2); |
| 1231 |
g_assert_cmpstr (str2, ==, wp_spa_json_get_data (json2)); |
| 1232 |
g_assert_cmpstr (str2, ==, "[{\"key0\":\"val0\"}]"); |
| 1233 |
|
| 1234 |
g_value_unset (&next); |
| 1235 |
} |
| 1236 |
|
| 1237 |
{ |
| 1238 |
GValue next = G_VALUE_INIT; |
| 1239 |
g_assert_true (wp_iterator_next (it, &next)); |
| 1240 |
WpSpaJson *o = g_value_get_boxed (&next); |
| 1241 |
g_assert_nonnull (o); |
| 1242 |
g_assert_true (wp_spa_json_is_object (o)); |
| 1243 |
g_autofree gchar *str = wp_spa_json_to_string (o); |
| 1244 |
g_assert_cmpstr (str, ==, "{\"key1\":\"val1\"}"); |
| 1245 |
g_assert_cmpstr (str, !=, wp_spa_json_get_data (o)); |
| 1246 |
|
| 1247 |
g_autoptr (WpSpaJsonBuilder) b = wp_spa_json_builder_new_array (); |
| 1248 |
wp_spa_json_builder_add_json (b, o); |
| 1249 |
g_autoptr (WpSpaJson) json2 = wp_spa_json_builder_end (b); |
| 1250 |
g_autofree gchar *str2 = wp_spa_json_to_string (json2); |
| 1251 |
g_assert_cmpstr (str2, ==, wp_spa_json_get_data (json2)); |
| 1252 |
g_assert_cmpstr (str2, ==, "[{\"key1\":\"val1\"}]"); |
| 1253 |
|
| 1254 |
g_value_unset (&next); |
| 1255 |
} |
| 1256 |
} |
| 1257 |
|
| 1258 |
static void |
| 1259 |
test_spa_json_undefined_parser (void) |
| 1260 |
{ |
| 1261 |
const gchar json_str[] = "key0 = val0, key.array = [ val1 val2 ], " |
| 1262 |
"key.object = { key-boolean = false, key-int = 8, key-array = [ 2 4 ] }"; |
| 1263 |
g_autoptr (WpSpaJson) json = wp_spa_json_new_wrap_string (json_str); |
| 1264 |
g_assert_nonnull (json); |
| 1265 |
|
| 1266 |
g_assert_false (wp_spa_json_is_container (json)); |
| 1267 |
|
| 1268 |
g_autoptr (WpSpaJsonParser) p = wp_spa_json_parser_new_undefined (json); |
| 1269 |
g_assert_nonnull (p); |
| 1270 |
|
| 1271 |
{ |
| 1272 |
g_autofree gchar *k = wp_spa_json_parser_get_string (p); |
| 1273 |
g_assert_cmpstr (k, ==, "key0"); |
| 1274 |
} |
| 1275 |
{ |
| 1276 |
g_autofree gchar *v = wp_spa_json_parser_get_string (p); |
| 1277 |
g_assert_cmpstr (v, ==, "val0"); |
| 1278 |
} |
| 1279 |
{ |
| 1280 |
g_autofree gchar *k = wp_spa_json_parser_get_string (p); |
| 1281 |
g_assert_cmpstr (k, ==, "key.array"); |
| 1282 |
} |
| 1283 |
{ |
| 1284 |
g_autoptr (WpSpaJson) v = wp_spa_json_parser_get_json (p); |
| 1285 |
g_autofree gchar *str = wp_spa_json_to_string (v); |
| 1286 |
g_assert_cmpstr (str, ==, "[ val1 val2 ]"); |
| 1287 |
g_assert_true (wp_spa_json_is_array (v)); |
| 1288 |
} |
| 1289 |
{ |
| 1290 |
g_autofree gchar *k = wp_spa_json_parser_get_string (p); |
| 1291 |
g_assert_cmpstr (k, ==, "key.object"); |
| 1292 |
} |
| 1293 |
{ |
| 1294 |
g_autoptr (WpSpaJson) v = wp_spa_json_parser_get_json (p); |
| 1295 |
g_autofree gchar *str = wp_spa_json_to_string (v); |
| 1296 |
g_assert_cmpstr (str, ==, "{ key-boolean = false, key-int = 8, key-array = [ 2 4 ] }"); |
| 1297 |
g_assert_true (wp_spa_json_is_object (v)); |
| 1298 |
} |
| 1299 |
{ |
| 1300 |
g_autofree gchar *k = wp_spa_json_parser_get_string (p); |
| 1301 |
g_assert_null (k); |
| 1302 |
} |
| 1303 |
{ |
| 1304 |
g_autofree gchar *k = wp_spa_json_parser_get_string (p); |
| 1305 |
g_assert_null (k); |
| 1306 |
} |
| 1307 |
} |
| 1308 |
|
| 1309 |
int |
| 1310 |
main (int argc, char *argv[]) |
| 1311 |
{ |
| 1312 |
g_test_init (&argc, &argv, NULL); |
| 1313 |
g_log_set_writer_func (wp_log_writer_default, NULL, NULL); |
| 1314 |
|
| 1315 |
g_test_add_func ("/wp/spa-json/basic", test_spa_json_basic); |
| 1316 |
g_test_add_func ("/wp/spa-json/array-builder-parser-iterator", |
| 1317 |
test_spa_json_array_builder_parser_iterator); |
| 1318 |
g_test_add_func ("/wp/spa-json/object-builder-parser-iterator", |
| 1319 |
test_spa_json_object_builder_parser_iterator); |
| 1320 |
g_test_add_func ("/wp/spa-json/nested", test_spa_json_nested); |
| 1321 |
g_test_add_func ("/wp/spa-json/nested2", test_spa_json_nested2); |
| 1322 |
g_test_add_func ("/wp/spa-json/nested3", test_spa_json_nested3); |
| 1323 |
g_test_add_func ("/wp/spa-json/ownership", test_spa_json_ownership); |
| 1324 |
g_test_add_func ("/wp/spa-json/spa-format", test_spa_json_spa_format); |
| 1325 |
g_test_add_func ("/wp/spa-json/to-string", test_spa_json_to_string); |
| 1326 |
g_test_add_func ("/wp/spa-json/undefined-parser", |
| 1327 |
test_spa_json_undefined_parser); |
| 1328 |
|
| 1329 |
return g_test_run (); |
| 1330 |
} |