test_charcase.c 762 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stddef.h>
  4. #include <string.h>
  5. #include <assert.h>
  6. #include "json.h"
  7. #include "json_tokener.h"
  8. static void test_case_parse(void);
  9. int main(int argc, char **argv)
  10. {
  11. MC_SET_DEBUG(1);
  12. test_case_parse();
  13. }
  14. /* make sure only lowercase forms are parsed in strict mode */
  15. static void test_case_parse()
  16. {
  17. struct json_tokener *tok;
  18. json_object *new_obj;
  19. tok = json_tokener_new();
  20. json_tokener_set_flags(tok, JSON_TOKENER_STRICT);
  21. new_obj = json_tokener_parse_ex(tok, "True", 4);
  22. assert (new_obj == NULL);
  23. new_obj = json_tokener_parse_ex(tok, "False", 5);
  24. assert (new_obj == NULL);
  25. new_obj = json_tokener_parse_ex(tok, "Null", 4);
  26. assert (new_obj == NULL);
  27. printf("OK\n");
  28. json_tokener_free(tok);
  29. }