mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Fix tests for all combinations of int/longlong and double/float
This commit is contained in:
@@ -43,7 +43,7 @@ static void assert_is_number(cJSON *number_item)
|
||||
assert_has_no_string(number_item);
|
||||
}
|
||||
|
||||
static void assert_parse_number(const char *string, cJSON_int integer, double real)
|
||||
static void assert_parse_number(const char *string, cJSON_int integer, cJSON_float real)
|
||||
{
|
||||
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
|
||||
buffer.content = (const unsigned char*)string;
|
||||
@@ -56,7 +56,11 @@ static void assert_parse_number(const char *string, cJSON_int integer, double re
|
||||
#else
|
||||
TEST_ASSERT_EQUAL_INT(integer, item->valueint);
|
||||
#endif
|
||||
#ifdef CJSON_FLOAT_USE_FLOAT
|
||||
TEST_ASSERT_EQUAL_FLOAT(real, item->valuedouble);
|
||||
#else
|
||||
TEST_ASSERT_EQUAL_DOUBLE(real, item->valuedouble);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void parse_number_should_parse_zero(void)
|
||||
@@ -96,11 +100,15 @@ static void parse_number_should_parse_positive_reals(void)
|
||||
assert_parse_number("10e-10", 0, 10e-10);
|
||||
assert_parse_number("10E-10", 0, 10e-10);
|
||||
#ifdef CJSON_INT_USE_LONGLONG
|
||||
#ifndef CJSON_FLOAT_USE_FLOAT
|
||||
assert_parse_number("10e10", 100000000000LL, 10e10);
|
||||
#endif
|
||||
#endif
|
||||
assert_parse_number("10e20", CJSON_INT_MAX, 10e20);
|
||||
#ifndef CJSON_FLOAT_USE_FLOAT
|
||||
assert_parse_number("123e+127", CJSON_INT_MAX, 123e127);
|
||||
assert_parse_number("123e-128", 0, 123e-128);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void parse_number_should_parse_negative_reals(void)
|
||||
@@ -109,11 +117,15 @@ static void parse_number_should_parse_negative_reals(void)
|
||||
assert_parse_number("-10e-10", 0, -10e-10);
|
||||
assert_parse_number("-10E-10", 0, -10e-10);
|
||||
#ifdef CJSON_INT_USE_LONGLONG
|
||||
#ifndef CJSON_FLOAT_USE_FLOAT
|
||||
assert_parse_number("-10e10", -100000000000LL, -10e10);
|
||||
#endif
|
||||
#endif
|
||||
assert_parse_number("-10e20", CJSON_INT_MIN, -10e20);
|
||||
#ifndef CJSON_FLOAT_USE_FLOAT
|
||||
assert_parse_number("-123e+127", CJSON_INT_MIN, -123e127);
|
||||
assert_parse_number("-123e-128", 0, -123e-128);
|
||||
#endif
|
||||
}
|
||||
|
||||
int CJSON_CDECL main(void)
|
||||
|
||||
Reference in New Issue
Block a user