+}
+
+static void encode_other_than_array_or_object()
+{
+ /* Encoding anything other than array or object should only
+ * succeed if the JSON_ENCODE_ANY flag is used */
+
+ json_t *json;
+ FILE *fp = NULL;
+ char *result;
+
+ json = json_string("foo");
+ if(json_dumps(json, 0) != NULL)
+ fail("json_dumps encoded a string!");
+ if(json_dumpf(json, fp, 0) == 0)
+ fail("json_dumpf encoded a string!");
+
+ result = json_dumps(json, JSON_ENCODE_ANY);
+ if(!result || strcmp(result, "\"foo\"") != 0)
+ fail("json_dumps failed to encode a string with JSON_ENCODE_ANY");
+
+ free(result);
+ json_decref(json);
+
+ json = json_integer(42);
+ if(json_dumps(json, 0) != NULL)
+ fail("json_dumps encoded an integer!");
+ if(json_dumpf(json, fp, 0) == 0)
+ fail("json_dumpf encoded an integer!");
+
+ result = json_dumps(json, JSON_ENCODE_ANY);
+ if(!result || strcmp(result, "42") != 0)
+ fail("json_dumps failed to encode an integer with JSON_ENCODE_ANY");
+
+ free(result);
+ json_decref(json);
+