#include <math.h>
#include "alloc-util.h"
+#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "json-internal.h"
void *state = NULL;
va_list ap;
+ _cleanup_free_ char *cdata;
+ assert_se(cdata = cescape(data));
+ log_info("/* %s data=\"%s\" */", __func__, cdata);
+
va_start(ap, data);
for (;;) {
_cleanup_free_ char *s = NULL;
int r;
+ _cleanup_free_ char *cdata;
+ assert_se(cdata = cescape(data));
+ log_info("/* %s data=\"%s\" */", __func__, cdata);
+
r = json_parse(data, 0, &v, NULL, NULL);
assert_se(r == 0);
assert_se(v);
JsonVariant *p, *q;
unsigned i;
+ log_info("/* %s */", __func__);
+
/* 3 keys + 3 values */
assert_se(json_variant_elements(v) == 6);
static void test_2(JsonVariant *v) {
JsonVariant *p, *q;
+ log_info("/* %s */", __func__);
+
/* 2 keys + 2 values */
assert_se(json_variant_elements(v) == 4);
}
static void test_zeroes(JsonVariant *v) {
- size_t i;
-
/* Make sure zero is how we expect it. */
+ log_info("/* %s */", __func__);
assert_se(json_variant_elements(v) == 13);
- for (i = 0; i < json_variant_elements(v); i++) {
+ for (size_t i = 0; i < json_variant_elements(v); i++) {
JsonVariant *w;
size_t j;
}
static void test_build(void) {
+ log_info("/* %s */", __func__);
+
_cleanup_(json_variant_unrefp) JsonVariant *a = NULL, *b = NULL;
_cleanup_free_ char *s = NULL, *t = NULL;
"false, 7.5, {} ]\n"
"}\n";
+ log_info("/* %s */", __func__);
+
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
}
static void test_depth(void) {
+ log_info("/* %s */", __func__);
+
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
- unsigned i;
int r;
v = JSON_VARIANT_STRING_CONST("start");
/* Let's verify that the maximum depth checks work */
- for (i = 0;; i++) {
+ for (unsigned i = 0;; i++) {
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
assert_se(i <= UINT16_MAX);
}
static void test_normalize(void) {
+ log_info("/* %s */", __func__);
+
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL;
_cleanup_free_ char *t = NULL;
}
static void test_bisect(void) {
+ log_info("/* %s */", __func__);
+
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
- char c;
/* Tests the bisection logic in json_variant_by_key() */
- for (c = 'z'; c >= 'a'; c--) {
+ for (char c = 'z'; c >= 'a'; c--) {
if ((c % 3) == 0)
continue;
json_variant_dump(v, JSON_FORMAT_COLOR|JSON_FORMAT_PRETTY, NULL, NULL);
- for (c = 'a'; c <= 'z'; c++) {
+ for (char c = 'a'; c <= 'z'; c++) {
JsonVariant *k;
const char *z;