Bläddra i källkod

parse_with_opts: test return_parse_end

Max Bruckner 8 år sedan
förälder
incheckning
bc0bb7c224
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12 0
      tests/parse_with_opts.c

+ 12 - 0
tests/parse_with_opts.c

@@ -58,6 +58,17 @@ static void parse_with_opts_should_require_null_if_requested(void)
     TEST_ASSERT_NULL(cJSON_ParseWithOpts("{}x", NULL, true));
 }
 
+static void parse_with_opts_should_return_parse_end(void)
+{
+    const char json[] = "[] empty array XD";
+    const char *parse_end = NULL;
+
+    cJSON *item = cJSON_ParseWithOpts(json, &parse_end, false);
+    TEST_ASSERT_NOT_NULL(item);
+    TEST_ASSERT_EQUAL_INT(2, parse_end - json);
+    cJSON_Delete(item);
+}
+
 int main(void)
 {
     UNITY_BEGIN();
@@ -65,6 +76,7 @@ int main(void)
     RUN_TEST(parse_with_opts_should_handle_null);
     RUN_TEST(parse_with_opts_should_handle_empty_strings);
     RUN_TEST(parse_with_opts_should_require_null_if_requested);
+    RUN_TEST(parse_with_opts_should_return_parse_end);
 
     return UNITY_END();
 }