mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-01 03:24:41 +01:00
305795b01e
It's the only user of them, and it's going to get optimized. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> gossip.pydiff --git a/common/test/run-json.c b/common/test/run-json.c index 956fdda35..db52d6b01 100644
49 lines
1.0 KiB
C
49 lines
1.0 KiB
C
#include "../json.c"
|
|
#include <common/utils.h>
|
|
#include <stdio.h>
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
|
// 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;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
setup_locale();
|
|
|
|
test_json_tok_bitcoin_amount();
|
|
assert(!taken_any());
|
|
take_cleanup();
|
|
}
|