2017-11-01 02:58:44 +01:00
|
|
|
#include "../json.c"
|
2018-04-25 12:55:34 +02:00
|
|
|
#include <common/utils.h>
|
2017-11-01 02:58:44 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
2018-01-12 17:46:12 +01:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2018-04-25 12:55:34 +02:00
|
|
|
setup_locale();
|
|
|
|
|
2018-01-12 17:46:12 +01:00
|
|
|
test_json_tok_bitcoin_amount();
|
2018-03-26 02:08:15 +02:00
|
|
|
assert(!taken_any());
|
|
|
|
take_cleanup();
|
2018-01-12 17:46:12 +01:00
|
|
|
}
|