diff options
author | Andris Zeila <andris.zeila@zabbix.com> | 2019-05-29 10:36:17 +0300 |
---|---|---|
committer | Andris Zeila <andris.zeila@zabbix.com> | 2019-05-29 11:20:58 +0300 |
commit | 2ad0f6e57e10e6ec2e5cb388b20f6fbcefdc87fe (patch) | |
tree | 3487d2adc58c585e9fa180d1f0a6323cb32e1575 /tests/libs/zbxjson | |
parent | 1150e17faac99eaccd3ea9363ecaa05e27066b3e (diff) |
.......PS. [ZBX-16151] fixed theoretical possibility of large numbers in json data being truncated, added boolean value support to json parser
* commit '9f6b629f6f46f89d251a336a7fbce728d8b8bf4d':
.......... [ZBX-16151] added changelog entry
.......... [ZBX-16151] added cmocka tests for zbx_json_decodevalue_dyn function
.......... [ZBX-16151] added cmocka tests for zbx_json_decodevalue function
.......PS. [ZBX-16151] backported json large number fix and boolean value support
(cherry picked from commit a41263020188a0ae22ecbd3e55c39ba54d3f95f1)
(cherry picked from commit 08dcbd76edf035a9c0a56544609cf7657bbfced0)
Diffstat (limited to 'tests/libs/zbxjson')
-rw-r--r-- | tests/libs/zbxjson/Makefile.am | 43 | ||||
-rw-r--r-- | tests/libs/zbxjson/mock_json.c | 38 | ||||
-rw-r--r-- | tests/libs/zbxjson/mock_json.h | 25 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_json_decodevalue.c | 63 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_json_decodevalue.yaml | 357 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_json_decodevalue_dyn.c | 63 | ||||
-rw-r--r-- | tests/libs/zbxjson/zbx_json_decodevalue_dyn.yaml | 383 |
7 files changed, 971 insertions, 1 deletions
diff --git a/tests/libs/zbxjson/Makefile.am b/tests/libs/zbxjson/Makefile.am index 2fc552ad79d..e1d549a2e5b 100644 --- a/tests/libs/zbxjson/Makefile.am +++ b/tests/libs/zbxjson/Makefile.am @@ -1,4 +1,8 @@ -noinst_PROGRAMS = jsonpath_next zbx_json_path_open +noinst_PROGRAMS = \ + jsonpath_next \ + zbx_json_path_open \ + zbx_json_decodevalue \ + zbx_json_decodevalue_dyn JSON_LIBS = \ $(top_srcdir)/tests/libzbxmocktest.a \ @@ -17,6 +21,8 @@ JSON_LIBS = \ $(top_srcdir)/src/libs/zbxconf/libzbxconf.a \ $(top_srcdir)/tests/libzbxmockdata.a +# jsonpath_next + jsonpath_next_SOURCES = \ jsonpath_next.c \ ../../zbxmocktest.h @@ -30,6 +36,8 @@ endif jsonpath_next_CFLAGS = -I@top_srcdir@/tests +# zbx_json_path_open + zbx_json_path_open_SOURCES = \ zbx_json_path_open.c \ ../../zbxmocktest.h @@ -42,3 +50,36 @@ zbx_json_path_open_LDFLAGS = @SERVER_LDFLAGS@ endif zbx_json_path_open_CFLAGS = -I@top_srcdir@/tests + +# zbx_json_decodevalue + +zbx_json_decodevalue_SOURCES = \ + zbx_json_decodevalue.c \ + mock_json.c mock_json.h \ + ../../zbxmocktest.h + +zbx_json_decodevalue_LDADD = $(JSON_LIBS) + +if SERVER +zbx_json_decodevalue_LDADD += @SERVER_LIBS@ +zbx_json_decodevalue_LDFLAGS = @SERVER_LDFLAGS@ +endif + +zbx_json_decodevalue_CFLAGS = -I@top_srcdir@/tests + +# zbx_json_decodevalue_dyn + +zbx_json_decodevalue_dyn_SOURCES = \ + zbx_json_decodevalue_dyn.c \ + mock_json.c mock_json.h \ + ../../zbxmocktest.h + +zbx_json_decodevalue_dyn_LDADD = $(JSON_LIBS) + +if SERVER +zbx_json_decodevalue_dyn_LDADD += @SERVER_LIBS@ +zbx_json_decodevalue_dyn_LDFLAGS = @SERVER_LDFLAGS@ +endif + +zbx_json_decodevalue_dyn_CFLAGS = -I@top_srcdir@/tests + diff --git a/tests/libs/zbxjson/mock_json.c b/tests/libs/zbxjson/mock_json.c new file mode 100644 index 00000000000..56172b0b3ac --- /dev/null +++ b/tests/libs/zbxjson/mock_json.c @@ -0,0 +1,38 @@ +/* +** Zabbix +** Copyright (C) 2001-2019 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#include "zbxmocktest.h" +#include "zbxmockdata.h" +#include "zbxmockassert.h" + +#include "common.h" +#include "zbxjson.h" + +const char *zbx_mock_json_type_to_str(int type) +{ + static const char *json_types[] = { + "ZBX_JSON_TYPE_UNKNOWN", "ZBX_JSON_TYPE_STRING", "ZBX_JSON_TYPE_INT", + "ZBX_JSON_TYPE_ARRAY", "ZBX_JSON_TYPE_OBJECT", "ZBX_JSON_TYPE_NULL", + "ZBX_JSON_TYPE_TRUE", "ZBX_JSON_TYPE_FALSE"}; + + if (0 > type || ZBX_JSON_TYPE_FALSE < type) + fail_msg("Unknown json type: %d", type); + + return json_types[type]; +} diff --git a/tests/libs/zbxjson/mock_json.h b/tests/libs/zbxjson/mock_json.h new file mode 100644 index 00000000000..7926bef73c9 --- /dev/null +++ b/tests/libs/zbxjson/mock_json.h @@ -0,0 +1,25 @@ +/* +** Zabbix +** Copyright (C) 2001-2019 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#ifndef ZABBIX_MOCK_JSON_H +#define ZABBIX_MOCK_JSON_H + +const char *zbx_mock_json_type_to_str(int type); + +#endif diff --git a/tests/libs/zbxjson/zbx_json_decodevalue.c b/tests/libs/zbxjson/zbx_json_decodevalue.c new file mode 100644 index 00000000000..85f9c807301 --- /dev/null +++ b/tests/libs/zbxjson/zbx_json_decodevalue.c @@ -0,0 +1,63 @@ +/* +** Zabbix +** Copyright (C) 2001-2019 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#include "common.h" +#include "zbxjson.h" + +#include "zbxmocktest.h" +#include "zbxmockdata.h" +#include "zbxmockassert.h" +#include "zbxmockutil.h" + +#include "mock_json.h" + +void zbx_mock_test_entry(void **state) +{ + const char *data, *result; + size_t size; + char *buffer; + int expected_offset; + zbx_json_type_t returned_type; + + ZBX_UNUSED(state); + + data = zbx_mock_get_parameter_string("in.data"); + size = zbx_mock_get_parameter_uint64("in.size"); + buffer = (0 != size ? (char *)zbx_malloc(NULL, size) : NULL); + + result = zbx_json_decodevalue(data, buffer, size, &returned_type); + + expected_offset = atoi(zbx_mock_get_parameter_string("out.offset")); + + if (0 == expected_offset) + zbx_mock_assert_ptr_eq("Returned value", NULL, result); + else + zbx_mock_assert_ptr_ne("Returned value", NULL, result); + + if (NULL != result) + { + zbx_mock_assert_int_eq("Returned value offset", expected_offset, result - data); + zbx_mock_assert_str_eq("Returned json type", zbx_mock_get_parameter_string("out.type"), + zbx_mock_json_type_to_str(returned_type)); + zbx_mock_assert_str_eq("Returned value", buffer, zbx_mock_get_parameter_string("out.value")); + } + + zbx_free(buffer); +} + diff --git a/tests/libs/zbxjson/zbx_json_decodevalue.yaml b/tests/libs/zbxjson/zbx_json_decodevalue.yaml new file mode 100644 index 00000000000..0878b95bcae --- /dev/null +++ b/tests/libs/zbxjson/zbx_json_decodevalue.yaml @@ -0,0 +1,357 @@ +--- +test case: Decode fail '' +in: + data: '' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'a b' +in: + data: 'a b' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail ' 1' +in: + data: ' 1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '+1' +in: + data: '+1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '--1' +in: + data: '--1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '.5' +in: + data: '.5' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '01' +in: + data: '01' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a\X"' +in: + data: '"a\X"' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a\' +in: + data: '"a\' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a' +in: + data: '"a' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"' +in: + data: '"' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '[1, 2]' +in: + data: '[1, 2]' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '{"a":1}' +in: + data: '{"a":1}' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'NULL' +in: + data: 'NULL' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'TRUE' +in: + data: 'TRUE' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'FALSE' +in: + data: 'FALSE' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"longer value"' with small output buffer +in: + data: '"longer value"' + size: 10 +out: + offset: 0 +--- +test case: Decode fail '12345678901234567890' with small output buffer +in: + data: '12345678901234567890' + size: 10 +out: + offset: 0 +--- +test case: Decode fail 'true' with small output buffer +in: + data: 'true' + size: 2 +out: + offset: 0 +--- +test case: Decode fail 'false' with small output buffer +in: + data: 'false' + size: 2 +out: + offset: 0 +--- +test case: Decode fail 'null' with small output buffer +in: + data: 'null' + size: 0 +out: + offset: 0 +--- +test case: Decode fail '"text"' with 0 output buffer +in: + data: '"text"' + size: 0 +out: + offset: 0 +--- +test case: Decode fail 'true' with 0 output buffer +in: + data: 'true' + size: 0 +out: + offset: 0 +--- +test case: Decode fail 'false' with 0 output buffer +in: + data: 'false' + size: 0 +out: + offset: 0 +--- +test case: Decode fail 'null' with 0 output buffer +in: + data: 'null' + size: 0 +out: + offset: 0 +--- +test case: Decode fail '12345' with 0 output buffer +in: + data: '12345' + size: 0 +out: + offset: 0 +--- +test case: Decode success '1' +in: + data: '1' + size: 1024 +out: + offset: 1 + type: ZBX_JSON_TYPE_INT + value: '1' +--- +test case: Decode success '1.5' +in: + data: '1.5' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_INT + value: '1.5' +--- +test case: Decode success '-1' +in: + data: '-1' + size: 1024 +out: + offset: 2 + type: ZBX_JSON_TYPE_INT + value: '-1' +--- +test case: Decode success '0' +in: + data: '0' + size: 1024 +out: + offset: 1 + type: ZBX_JSON_TYPE_INT + value: '0' +--- +test case: Decode success '1e5' +in: + data: '1e5' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_INT + value: '1e5' +--- +test case: Decode success '1e-2' +in: + data: '1e-2' + size: 1024 +out: + offset: 4 + type: ZBX_JSON_TYPE_INT + value: '1e-2' +--- +test case: Decode success '-0.5E10' +in: + data: '-0.5E10' + size: 1024 +out: + offset: 7 + type: ZBX_JSON_TYPE_INT + value: '-0.5E10' +--- +test case: Decode success '-0.5E+10' +in: + data: '-0.5E+10' + size: 1024 +out: + offset: 8 + type: ZBX_JSON_TYPE_INT + value: '-0.5E+10' +--- +test case: Decode success '1e03' +in: + data: '1e03' + size: 1024 +out: + offset: 4 + type: ZBX_JSON_TYPE_INT + value: '1e03' +--- +test case: Decode success 'true' +in: + data: 'true' + size: 5 +out: + offset: 4 + type: ZBX_JSON_TYPE_TRUE + value: 'true' +--- +test case: Decode fail 'true' with output buffer 1 byte less than needed +in: + data: 'true' + size: 4 +out: + offset: 0 +--- +test case: Decode success 'false' +in: + data: 'false' + size: 6 +out: + offset: 5 + type: ZBX_JSON_TYPE_FALSE + value: 'false' +--- +test case: Decode fail 'false' with output buffer 1 byte less than needed +in: + data: 'false' + size: 5 +out: + offset: 0 +--- +test case: Decode success 'null' +in: + data: 'null' + size: 1 +out: + offset: 4 + type: ZBX_JSON_TYPE_NULL + value: '' +--- +test case: Decode success '"a"' +in: + data: '"a"' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_STRING + value: 'a' +--- +test case: Decode success '"\\/"' +in: + data: '"\\/"' + size: 1024 +out: + offset: 5 + type: ZBX_JSON_TYPE_STRING + value: '\/' +--- +test case: Decode success '"value \"1\""' +in: + data: '"value \"1\""' + size: 1024 +out: + offset: 13 + type: ZBX_JSON_TYPE_STRING + value: 'value "1"' +--- +test case: Decode success '"value \"1\""'with output buffer having the required size +in: + data: '"value \"1\""' + size: 10 +out: + offset: 13 + type: ZBX_JSON_TYPE_STRING + value: 'value "1"' +--- +test case: Decode fail '"value \"1\""' with output buffer 1 byte less than needed +in: + data: '"value \"1\""' + size: 9 +out: + offset: 0 +--- +test case: Decode success '"\u0420\u0435\u0433\u0438\u043e\u043d"' +in: + data: '"\u0420\u0435\u0433\u0438\u043e\u043d"' + size: 1024 +out: + offset: 38 + type: ZBX_JSON_TYPE_STRING + value: 'Регион' +... diff --git a/tests/libs/zbxjson/zbx_json_decodevalue_dyn.c b/tests/libs/zbxjson/zbx_json_decodevalue_dyn.c new file mode 100644 index 00000000000..978e457be92 --- /dev/null +++ b/tests/libs/zbxjson/zbx_json_decodevalue_dyn.c @@ -0,0 +1,63 @@ +/* +** Zabbix +** Copyright (C) 2001-2019 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#include "common.h" +#include "zbxjson.h" + +#include "zbxmocktest.h" +#include "zbxmockdata.h" +#include "zbxmockassert.h" +#include "zbxmockutil.h" + +#include "mock_json.h" + +void zbx_mock_test_entry(void **state) +{ + const char *data, *result; + size_t size; + char *buffer; + int expected_offset; + zbx_json_type_t returned_type; + + ZBX_UNUSED(state); + + data = zbx_mock_get_parameter_string("in.data"); + size = zbx_mock_get_parameter_uint64("in.size"); + buffer = (0 != size ? (char *)zbx_malloc(NULL, size) : NULL); + + result = zbx_json_decodevalue_dyn(data, &buffer, &size, &returned_type); + + expected_offset = atoi(zbx_mock_get_parameter_string("out.offset")); + + if (0 == expected_offset) + zbx_mock_assert_ptr_eq("Returned value", NULL, result); + else + zbx_mock_assert_ptr_ne("Returned value", NULL, result); + + if (NULL != result) + { + zbx_mock_assert_int_eq("Returned value offset", expected_offset, result - data); + zbx_mock_assert_str_eq("Returned json type", zbx_mock_get_parameter_string("out.type"), + zbx_mock_json_type_to_str(returned_type)); + zbx_mock_assert_str_eq("Returned value", buffer, zbx_mock_get_parameter_string("out.value")); + } + + zbx_free(buffer); +} + diff --git a/tests/libs/zbxjson/zbx_json_decodevalue_dyn.yaml b/tests/libs/zbxjson/zbx_json_decodevalue_dyn.yaml new file mode 100644 index 00000000000..7bded75b515 --- /dev/null +++ b/tests/libs/zbxjson/zbx_json_decodevalue_dyn.yaml @@ -0,0 +1,383 @@ +--- +test case: Decode fail '' +in: + data: '' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'a b' +in: + data: 'a b' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail ' 1' +in: + data: ' 1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '+1' +in: + data: '+1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '--1' +in: + data: '--1' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '.5' +in: + data: '.5' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '01' +in: + data: '01' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a\X"' +in: + data: '"a\X"' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a\' +in: + data: '"a\' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"a' +in: + data: '"a' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '"' +in: + data: '"' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '[1, 2]' +in: + data: '[1, 2]' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail '{"a":1}' +in: + data: '{"a":1}' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'NULL' +in: + data: 'NULL' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'TRUE' +in: + data: 'TRUE' + size: 1024 +out: + offset: 0 +--- +test case: Decode fail 'FALSE' +in: + data: 'FALSE' + size: 1024 +out: + offset: 0 +--- +test case: Decode success '"longer value"' with small output buffer +in: + data: '"longer value"' + size: 10 +out: + offset: 14 + type: ZBX_JSON_TYPE_STRING + value: longer value +--- +test case: Decode success '12345678901234567890' with small output buffer +in: + data: '12345678901234567890' + size: 10 +out: + offset: 20 + type: ZBX_JSON_TYPE_INT + value: 12345678901234567890 +--- +test case: Decode fail 'true' with small output buffer +in: + data: 'true' + size: 2 +out: + offset: 4 + type: ZBX_JSON_TYPE_TRUE + value: true +--- +test case: Decode fail 'false' with small output buffer +in: + data: 'false' + size: 2 +out: + offset: 5 + type: ZBX_JSON_TYPE_FALSE + value: false +--- +test case: Decode fail 'null' with small output buffer +in: + data: 'null' + size: 0 +out: + offset: 4 + type: ZBX_JSON_TYPE_NULL + value: '' +--- +test case: Decode fail '"text"' with 0 output buffer +in: + data: '"text"' + size: 0 +out: + offset: 6 + type: ZBX_JSON_TYPE_STRING + value: text +--- +test case: Decode fail 'true' with 0 output buffer +in: + data: 'true' + size: 0 +out: + offset: 4 + type: ZBX_JSON_TYPE_TRUE + value: true +--- +test case: Decode fail 'false' with 0 output buffer +in: + data: 'false' + size: 0 +out: + offset: 5 + type: ZBX_JSON_TYPE_FALSE + value: false +--- +test case: Decode fail 'null' with 0 output buffer +in: + data: 'null' + size: 0 +out: + offset: 4 + type: ZBX_JSON_TYPE_NULL + value: '' +--- +test case: Decode fail '12345' with 0 output buffer +in: + data: '12345' + size: 0 +out: + offset: 5 + type: ZBX_JSON_TYPE_INT + value: 12345 +--- +test case: Decode success '1' +in: + data: '1' + size: 1024 +out: + offset: 1 + type: ZBX_JSON_TYPE_INT + value: '1' +--- +test case: Decode success '1.5' +in: + data: '1.5' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_INT + value: '1.5' +--- +test case: Decode success '-1' +in: + data: '-1' + size: 1024 +out: + offset: 2 + type: ZBX_JSON_TYPE_INT + value: '-1' +--- +test case: Decode success '0' +in: + data: '0' + size: 1024 +out: + offset: 1 + type: ZBX_JSON_TYPE_INT + value: '0' +--- +test case: Decode success '1e5' +in: + data: '1e5' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_INT + value: '1e5' +--- +test case: Decode success '1e-2' +in: + data: '1e-2' + size: 1024 +out: + offset: 4 + type: ZBX_JSON_TYPE_INT + value: '1e-2' +--- +test case: Decode success '-0.5E10' +in: + data: '-0.5E10' + size: 1024 +out: + offset: 7 + type: ZBX_JSON_TYPE_INT + value: '-0.5E10' +--- +test case: Decode success '-0.5E+10' +in: + data: '-0.5E+10' + size: 1024 +out: + offset: 8 + type: ZBX_JSON_TYPE_INT + value: '-0.5E+10' +--- +test case: Decode success '1e03' +in: + data: '1e03' + size: 1024 +out: + offset: 4 + type: ZBX_JSON_TYPE_INT + value: '1e03' +--- +test case: Decode success 'true' +in: + data: 'true' + size: 5 +out: + offset: 4 + type: ZBX_JSON_TYPE_TRUE + value: 'true' +--- +test case: Decode fail 'true' with output buffer 1 byte less than needed +in: + data: 'true' + size: 4 +out: + offset: 4 + type: ZBX_JSON_TYPE_TRUE + value: 'true' +--- +test case: Decode success 'false' +in: + data: 'false' + size: 6 +out: + offset: 5 + type: ZBX_JSON_TYPE_FALSE + value: 'false' +--- +test case: Decode fail 'false' with output buffer 1 byte less than needed +in: + data: 'false' + size: 5 +out: + offset: 5 + type: ZBX_JSON_TYPE_FALSE + value: 'false' +--- +test case: Decode success 'null' +in: + data: 'null' + size: 1 +out: + offset: 4 + type: ZBX_JSON_TYPE_NULL + value: '' +--- +test case: Decode success '"a"' +in: + data: '"a"' + size: 1024 +out: + offset: 3 + type: ZBX_JSON_TYPE_STRING + value: 'a' +--- +test case: Decode success '"\\/"' +in: + data: '"\\/"' + size: 1024 +out: + offset: 5 + type: ZBX_JSON_TYPE_STRING + value: '\/' +--- +test case: Decode success '"value \"1\""' +in: + data: '"value \"1\""' + size: 1024 +out: + offset: 13 + type: ZBX_JSON_TYPE_STRING + value: 'value "1"' +--- +test case: Decode success '"value \"1\""'with output buffer having the required size +in: + data: '"value \"1\""' + size: 10 +out: + offset: 13 + type: ZBX_JSON_TYPE_STRING + value: 'value "1"' +--- +test case: Decode fail '"value \"1\""' with output buffer 1 byte less than needed +in: + data: '"value \"1\""' + size: 9 +out: + offset: 13 + type: ZBX_JSON_TYPE_STRING + value: 'value "1"' +--- +test case: Decode success '"\u0420\u0435\u0433\u0438\u043e\u043d"' +in: + data: '"\u0420\u0435\u0433\u0438\u043e\u043d"' + size: 1024 +out: + offset: 38 + type: ZBX_JSON_TYPE_STRING + value: 'Регион' +... |