diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-17 17:10:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-17 17:10:38 +0200 |
commit | 2f67dbebc572f1c70c3bfcb39fec45591aea9bc8 (patch) | |
tree | 4ae3819d40efd9cf8a2ba2c60d1bcd2019a19016 /src/util/test_json.c | |
parent | b1401f93da11d38d49a5117d4f717fec384e7176 (diff) | |
download | exchange-2f67dbebc572f1c70c3bfcb39fec45591aea9bc8.tar.gz exchange-2f67dbebc572f1c70c3bfcb39fec45591aea9bc8.tar.bz2 exchange-2f67dbebc572f1c70c3bfcb39fec45591aea9bc8.zip |
test json-raw conversion, fix assertion
Diffstat (limited to 'src/util/test_json.c')
-rw-r--r-- | src/util/test_json.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/util/test_json.c b/src/util/test_json.c index a1a5cd54f..42968ba90 100644 --- a/src/util/test_json.c +++ b/src/util/test_json.c @@ -88,6 +88,37 @@ test_time () } +/** + * Test raw (binary) conversion from/to JSON. + * + * @return 0 on success + */ +static int +test_raw () +{ + char blob[256]; + char blob2[256]; + unsigned int i; + json_t *j; + + for (i=0;i<=256;i++) + { + memset (blob, i, i); + j = TALER_json_from_data (blob, i); + GNUNET_assert (NULL != j); + GNUNET_assert (GNUNET_OK == + TALER_json_to_data (j, + blob2, + i)); + GNUNET_assert (0 == + memcmp (blob, + blob2, + i)); + } + return 0; +} + + int main(int argc, const char *const argv[]) @@ -99,6 +130,8 @@ main(int argc, return 1; if (0 != test_time ()) return 1; + if (0 != test_raw ()) + return 1; /* FIXME: implement test... */ return 0; } |