This commit is contained in:
Daniel Lemire 2020-01-02 14:20:51 -05:00
parent 399d08c86c
commit ba9dc12164
2 changed files with 42 additions and 0 deletions

1
jsonchecker/fail78.json Normal file
View File

@ -0,0 +1 @@
[ 1, 2, 3, false

View File

@ -23,6 +23,45 @@ inline uint64_t f64_ulp_dist(double a, double b) {
return ua + ub + 0x80000000;
}
bool number_test_small_integers() {
char buf[1024];
simdjson::ParsedJson pj;
if (!pj.allocate_capacity(1024)) {
printf("allocation failure in number_test_small_integers\n");
return false;
}
for (int m = 10; m < 20; m++) {
for (int i = -1024; i < 1024; i++) {
auto n = sprintf(buf, "%*d", m, i);
buf[n] = '\0';
fflush(NULL);
auto ok1 = json_parse(buf, n, pj);
if (ok1 != 0 || !pj.is_valid()) {
printf("Could not parse: %s.\n", buf);
return false;
}
simdjson::ParsedJson::Iterator pjh(pj);
if(!pjh.is_number()) {
printf("Root should be number\n");
return false;
}
if(!pjh.is_integer()) {
printf("Root should be an integer\n");
return false;
}
int64_t x = pjh.get_integer();
if(x != i) {
printf("failed to parse %s. \n", buf);
return false;
}
}
}
printf("Small integers can be parsed.\n");
return true;
}
bool number_test_powers_of_two() {
char buf[1024];
simdjson::ParsedJson pj;
@ -325,6 +364,8 @@ bool skyprophet_test() {
int main() {
std::cout << "Running basic tests." << std::endl;
if(!number_test_small_integers())
return EXIT_FAILURE;
if(!stable_test())
return EXIT_FAILURE;
if(!bad_example())