Lines Matching refs:v

31                 JsonValue v = JSON_VALUE_NULL;  in test_tokenizer_one()  local
34 … t = json_tokenize(&data, &str, &v, &token_line, &token_column, &state, &line, &column); in test_tokenizer_one()
53 assert_se(fabsl(d - v.real) < 1e-10 || in test_tokenizer_one()
54 fabsl((d - v.real) / v.real) < 1e-10); in test_tokenizer_one()
60 assert_se(i == v.integer); in test_tokenizer_one()
66 assert_se(u == v.unsig); in test_tokenizer_one()
72 assert_se(b == v.boolean); in test_tokenizer_one()
82 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL; in test_variant_one()
90 r = json_parse(data, 0, &v, NULL, NULL); in test_variant_one()
92 assert_se(v); in test_variant_one()
94 r = json_variant_format(v, 0, &s); in test_variant_one()
104 assert_se(json_variant_has_type(v, json_variant_type(w))); in test_variant_one()
105 assert_se(json_variant_has_type(w, json_variant_type(v))); in test_variant_one()
106 assert_se(json_variant_equal(v, w)); in test_variant_one()
111 r = json_variant_format(v, JSON_FORMAT_PRETTY, &s); in test_variant_one()
122 assert_se(json_variant_has_type(v, json_variant_type(w))); in test_variant_one()
123 assert_se(json_variant_has_type(w, json_variant_type(v))); in test_variant_one()
124 assert_se(json_variant_equal(v, w)); in test_variant_one()
127 r = json_variant_format(v, JSON_FORMAT_COLOR, &s); in test_variant_one()
134 r = json_variant_format(v, JSON_FORMAT_COLOR|JSON_FORMAT_PRETTY, &s); in test_variant_one()
141 test(v); in test_variant_one()
144 static void test_1(JsonVariant *v) { in test_1() argument
151 assert_se(json_variant_elements(v) == 6); in test_1()
154 p = json_variant_by_key(v, "k"); in test_1()
161 p = json_variant_by_key(v, "foo"); in test_1()
172 p = json_variant_by_key(v, "bar"); in test_1()
180 static void test_2(JsonVariant *v) { in test_2() argument
186 assert_se(json_variant_elements(v) == 4); in test_2()
189 p = json_variant_by_key(v, "mutant"); in test_2()
223 p = json_variant_by_key(v, "thisisaverylongproperty"); in test_2()
227 static void test_zeroes(JsonVariant *v) { in test_zeroes() argument
231 assert_se(json_variant_elements(v) == 13); in test_zeroes()
233 for (size_t i = 0; i < json_variant_elements(v); i++) { in test_zeroes()
237 assert_se(w = json_variant_by_index(v, i)); in test_zeroes()
255 for (j = 0; j < json_variant_elements(v); j++) { in test_zeroes()
258 assert_se(q = json_variant_by_index(v, j)); in test_zeroes()
367 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; in TEST()
375 assert_se(json_parse_file(f, "waldo", 0, &v, NULL, NULL) >= 0); in TEST()
378 json_variant_dump(v, 0, stdout, NULL); in TEST()
382 json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, stdout, NULL); in TEST()
387 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; in TEST()
390 v = JSON_VARIANT_STRING_CONST("start"); in TEST()
399 r = json_variant_new_array(&w, &v, 1); in TEST()
401 … r = json_variant_new_object(&w, (JsonVariant*[]) { JSON_VARIANT_STRING_CONST("key"), v }, 2); in TEST()
416 json_variant_unref(v); in TEST()
417 v = TAKE_PTR(w); in TEST()
420 json_variant_dump(v, 0, stdout, NULL); in TEST()
425 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL; in TEST()
428 assert_se(json_build(&v, JSON_BUILD_OBJECT( in TEST()
433 assert_se(!json_variant_is_sorted(v)); in TEST()
434 assert_se(!json_variant_is_normalized(v)); in TEST()
436 assert_se(json_variant_format(v, 0, &t) >= 0); in TEST()
442 JSON_BUILD_PAIR("foo", JSON_BUILD_VARIANT(v)))) >= 0); in TEST()
451 assert_se(json_variant_sort(&v) >= 0); in TEST()
452 assert_se(json_variant_is_sorted(v)); in TEST()
453 assert_se(json_variant_is_normalized(v)); in TEST()
455 assert_se(json_variant_format(v, 0, &t) >= 0); in TEST()
469 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; in TEST()
480 assert_se(json_variant_set_field(&v, (char[2]) { c, 0 }, w) >= 0); in TEST()
483 json_variant_dump(v, JSON_FORMAT_COLOR|JSON_FORMAT_PRETTY, NULL, NULL); in TEST()
485 assert_se(!json_variant_is_sorted(v)); in TEST()
486 assert_se(!json_variant_is_normalized(v)); in TEST()
487 assert_se(json_variant_normalize(&v) >= 0); in TEST()
488 assert_se(json_variant_is_sorted(v)); in TEST()
489 assert_se(json_variant_is_normalized(v)); in TEST()
491 json_variant_dump(v, JSON_FORMAT_COLOR|JSON_FORMAT_PRETTY, NULL, NULL); in TEST()
497 k = json_variant_by_key(v, (char[2]) { c, 0 }); in TEST()
510 static void test_float_match(JsonVariant *v) { in test_float_match() argument
513 assert_se(json_variant_is_array(v)); in test_float_match()
514 assert_se(json_variant_elements(v) == 9); in test_float_match()
515 …absl((double) 1.0 - ((double) DBL_MIN / json_variant_real(json_variant_by_index(v, 0)))) <= delta); in test_float_match()
516 …absl((double) 1.0 - ((double) DBL_MAX / json_variant_real(json_variant_by_index(v, 1)))) <= delta); in test_float_match()
517 …assert_se(json_variant_is_null(json_variant_by_index(v, 2))); /* nan is not supported by json → nu… in test_float_match()
518 …assert_se(json_variant_is_null(json_variant_by_index(v, 3))); /* +inf is not supported by json → n… in test_float_match()
519 …assert_se(json_variant_is_null(json_variant_by_index(v, 4))); /* -inf is not supported by json → n… in test_float_match()
520 assert_se(json_variant_is_null(json_variant_by_index(v, 5)) || in test_float_match()
521 …(double) 1.0 - ((double) HUGE_VAL / json_variant_real(json_variant_by_index(v, 5)))) <= delta); /*… in test_float_match()
522 assert_se(json_variant_is_real(json_variant_by_index(v, 6)) && in test_float_match()
523 json_variant_is_integer(json_variant_by_index(v, 6)) && in test_float_match()
524 json_variant_integer(json_variant_by_index(v, 6)) == 0); in test_float_match()
525 assert_se(json_variant_is_real(json_variant_by_index(v, 7)) && in test_float_match()
526 json_variant_is_integer(json_variant_by_index(v, 7)) && in test_float_match()
527 json_variant_integer(json_variant_by_index(v, 7)) == 10); in test_float_match()
528 assert_se(json_variant_is_real(json_variant_by_index(v, 8)) && in test_float_match()
529 json_variant_is_integer(json_variant_by_index(v, 8)) && in test_float_match()
530 json_variant_integer(json_variant_by_index(v, 8)) == -10); in test_float_match()
534 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL; in TEST()
537 assert_se(json_build(&v, JSON_BUILD_ARRAY( in TEST()
548 json_variant_dump(v, JSON_FORMAT_COLOR|JSON_FORMAT_PRETTY, NULL, NULL); in TEST()
550 test_float_match(v); in TEST()
552 assert_se(json_variant_format(v, 0, &text) >= 0); in TEST()
560 static void test_equal_text(JsonVariant *v, const char *text) { in test_equal_text() argument
564 assert_se(json_variant_equal(v, w) || (!v && json_variant_is_null(w))); in test_equal_text()
568 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; in TEST()
570 test_equal_text(v, "null"); in TEST()
571 assert_se(json_variant_set_field(&v, "foo", NULL) >= 0); in TEST()
572 test_equal_text(v, "{\"foo\" : null}"); in TEST()
573 assert_se(json_variant_set_field(&v, "bar", JSON_VARIANT_STRING_CONST("quux")) >= 0); in TEST()
574 test_equal_text(v, "{\"foo\" : null, \"bar\" : \"quux\"}"); in TEST()
575 assert_se(json_variant_set_field(&v, "foo", JSON_VARIANT_STRING_CONST("quux2")) >= 0); in TEST()
576 test_equal_text(v, "{\"foo\" : \"quux2\", \"bar\" : \"quux\"}"); in TEST()
577 assert_se(json_variant_set_field(&v, "bar", NULL) >= 0); in TEST()
578 test_equal_text(v, "{\"foo\" : \"quux2\", \"bar\" : null}"); in TEST()