1--TEST--
2json_validate() - Error handling
3--FILE--
4<?php
5
6require_once("json_validate_requires.inc");
7
8json_validate_trycatchdump("");
9json_validate_trycatchdump("-");
10json_validate_trycatchdump("", -1);
11json_validate_trycatchdump('{"key1":"value1", "key2":"value2"}', 1);
12json_validate_trycatchdump('{"key1":"value1", "key2":"value2"}', 2);
13json_validate_trycatchdump("-", 0);
14json_validate_trycatchdump("-", 512, JSON_BIGINT_AS_STRING);
15json_validate_trycatchdump("-", 512, JSON_BIGINT_AS_STRING | JSON_INVALID_UTF8_IGNORE);
16json_validate_trycatchdump("-", 512, JSON_INVALID_UTF8_IGNORE);
17json_validate_trycatchdump("{}", 512, JSON_INVALID_UTF8_IGNORE);
18
19?>
20--EXPECTF--
21bool(false)
22int(4)
23string(12) "Syntax error"
24bool(false)
25int(4)
26string(12) "Syntax error"
27bool(false)
28int(4)
29string(12) "Syntax error"
30bool(false)
31int(1)
32string(28) "Maximum stack depth exceeded"
33bool(true)
34int(0)
35string(8) "No error"
36Error: 0 json_validate(): Argument #2 ($depth) must be greater than 0
37int(0)
38string(8) "No error"
39Error: 0 json_validate(): Argument #3 ($flags) must be a valid flag (allowed flags: JSON_INVALID_UTF8_IGNORE)
40int(0)
41string(8) "No error"
42Error: 0 json_validate(): Argument #3 ($flags) must be a valid flag (allowed flags: JSON_INVALID_UTF8_IGNORE)
43int(0)
44string(8) "No error"
45bool(false)
46int(4)
47string(12) "Syntax error"
48bool(true)
49int(0)
50string(8) "No error"
51