|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
#include <stdio.h>
|
|
Packit Service |
def718 |
#include <string.h>
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
#include "config.h"
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
#include "json_inttypes.h"
|
|
Packit Service |
def718 |
#include "json_util.h"
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
void checkit(const char *buf)
|
|
Packit Service |
def718 |
{
|
|
Packit Service |
def718 |
int64_t cint64 = -666;
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
int retval = json_parse_int64(buf, &cint64);
|
|
Packit Service |
def718 |
printf("buf=%s parseit=%d, value=%" PRId64 " \n", buf, retval, cint64);
|
|
Packit Service |
def718 |
}
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
/**
|
|
Packit Service |
def718 |
* This test calls json_parse_int64 with a variety of different strings.
|
|
Packit Service |
def718 |
* It's purpose is to ensure that the results are consistent across all
|
|
Packit Service |
def718 |
* different environments that it might be executed in.
|
|
Packit Service |
def718 |
*
|
|
Packit Service |
def718 |
* This always exits with a 0 exit value. The output should be compared
|
|
Packit Service |
def718 |
* against previously saved expected output.
|
|
Packit Service |
def718 |
*/
|
|
Packit Service |
def718 |
int main()
|
|
Packit Service |
def718 |
{
|
|
Packit Service |
def718 |
char buf[100];
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
checkit("x");
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
checkit("0");
|
|
Packit Service |
def718 |
checkit("-0");
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
checkit("00000000");
|
|
Packit Service |
def718 |
checkit("-00000000");
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
checkit("1");
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "2147483647"); // aka INT32_MAX
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-1");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, " -1");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "00001234");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "0001234x");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-00001234");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-00001234x");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "4294967295"); // aka UINT32_MAX
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
sprintf(buf, "4294967296"); // aka UINT32_MAX + 1
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "21474836470"); // INT32_MAX * 10
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "31474836470"); // INT32_MAX * 10 + a bunch
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-2147483647"); // INT32_MIN + 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-2147483648"); // INT32_MIN
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-2147483649"); // INT32_MIN - 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-21474836480"); // INT32_MIN * 10
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "9223372036854775806"); // INT64_MAX - 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "9223372036854775807"); // INT64_MAX
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "9223372036854775808"); // INT64_MAX + 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-9223372036854775808"); // INT64_MIN
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-9223372036854775809"); // INT64_MIN - 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "18446744073709551614"); // UINT64_MAX - 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "18446744073709551615"); // UINT64_MAX
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "18446744073709551616"); // UINT64_MAX + 1
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
strcpy(buf, "-18446744073709551616"); // -UINT64_MAX
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
// Ensure we can still parse valid numbers after parsing out of range ones.
|
|
Packit Service |
def718 |
strcpy(buf, "123");
|
|
Packit Service |
def718 |
checkit(buf);
|
|
Packit Service |
def718 |
|
|
Packit Service |
def718 |
return 0;
|
|
Packit Service |
def718 |
}
|