Exposing bug #420

This commit is contained in:
Daniel Lemire 2020-01-09 09:55:54 -05:00
parent 951c4bedf8
commit 6e5e0278c2
1 changed files with 43 additions and 0 deletions

View File

@ -266,6 +266,30 @@ bool navigate_test() {
printf("Root should be object\n"); printf("Root should be object\n");
return false; return false;
} }
if(pjh.move_to_key("bad key")) {
printf("We should not move to a non-existing key\n");
return false;
}
if(!pjh.is_object()) {
printf("We should have remained at the object.\n");
return false;
}
if(pjh.move_to_key_insensitive("bad key")) {
printf("We should not move to a non-existing key\n");
return false;
}
if(!pjh.is_object()) {
printf("We should have remained at the object.\n");
return false;
}
if(pjh.move_to_key("bad key", 7)) {
printf("We should not move to a non-existing key\n");
return false;
}
if(!pjh.is_object()) {
printf("We should have remained at the object.\n");
return false;
}
if(!pjh.down()) { if(!pjh.down()) {
printf("Root should not be emtpy\n"); printf("Root should not be emtpy\n");
return false; return false;
@ -303,6 +327,25 @@ bool navigate_test() {
printf("There should be a key Width.\n"); printf("There should be a key Width.\n");
return false; return false;
} }
if(!pjh.up()) {
return false;
}
if(!pjh.move_to_key("IDs")) {
printf("We should be able to move to an existing key\n");
return false;
}
if(!pjh.is_array()) {
printf("Value of IDs should be array, it is %c \n", pjh.get_type());
return false;
}
if(pjh.move_to_index(4)) {
printf("We should not be able to move to a non-existing index\n");
return false;
}
if(!pjh.is_array()) {
printf("We should have remained at the array\n");
return false;
}
return true; return true;
} }