diff options
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; } |