|
|
@ -4,7 +4,41 @@ |
|
|
|
/* AUTOGENERATED MOCKS START */ |
|
|
|
/* AUTOGENERATED MOCKS END */ |
|
|
|
|
|
|
|
int main(void) |
|
|
|
|
|
|
|
// issue #577
|
|
|
|
|
|
|
|
static void do_json_tok_bitcoin_amount(const char* val, uint64_t expected) |
|
|
|
{ |
|
|
|
uint64_t amount; |
|
|
|
jsmntok_t tok; |
|
|
|
|
|
|
|
tok.start = 0; |
|
|
|
tok.end = strlen(val); |
|
|
|
|
|
|
|
fprintf(stderr, "do_json_tok_bitcoin_amount(\"%s\", %"PRIu64"): ", val, expected); |
|
|
|
|
|
|
|
assert(json_tok_bitcoin_amount(val, &tok, &amount) == true); |
|
|
|
assert(amount == expected); |
|
|
|
|
|
|
|
fprintf(stderr, "ok\n"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int test_json_tok_bitcoin_amount(void) |
|
|
|
{ |
|
|
|
do_json_tok_bitcoin_amount("0.00000001", 1); |
|
|
|
do_json_tok_bitcoin_amount("0.00000007", 7); |
|
|
|
do_json_tok_bitcoin_amount("0.00000008", 8); |
|
|
|
do_json_tok_bitcoin_amount("0.00000010", 10); |
|
|
|
do_json_tok_bitcoin_amount("0.12345678", 12345678); |
|
|
|
do_json_tok_bitcoin_amount("0.01234567", 1234567); |
|
|
|
do_json_tok_bitcoin_amount("123.45678900", 12345678900); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int test_json_escape(void) |
|
|
|
{ |
|
|
|
struct json_result *result = new_json_result(NULL); |
|
|
|
jsmntok_t *toks; |
|
|
@ -43,3 +77,10 @@ int main(void) |
|
|
|
tal_free(result); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main(void) |
|
|
|
{ |
|
|
|
test_json_tok_bitcoin_amount(); |
|
|
|
test_json_escape(); |
|
|
|
} |
|
|
|