diff options
author | Glebs Ivanovskis <git-no-reply@zabbix.com> | 2018-01-18 15:24:33 +0300 |
---|---|---|
committer | Glebs Ivanovskis <git-no-reply@zabbix.com> | 2018-01-18 15:24:33 +0300 |
commit | cc0ff7592e483245179770e1065e36b24b21bf1d (patch) | |
tree | 76c6cb2e9cbec17ed14e8ce59b4401d35094ceeb /tests/libs/zbxconf/parse_cfg_file.c | |
parent | 5e8caf4312433cd1333d68a5f574e1292c8e86eb (diff) |
.......... [DEV-628] fixed getting in/out parameters, object members, files, db data, etc. by name; added few placeholders of global variables for mock tests; fixed a couple of issues with parse_cfg_file() test
Diffstat (limited to 'tests/libs/zbxconf/parse_cfg_file.c')
-rw-r--r-- | tests/libs/zbxconf/parse_cfg_file.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/tests/libs/zbxconf/parse_cfg_file.c b/tests/libs/zbxconf/parse_cfg_file.c index ccc4f8f89f5..131c8279c65 100644 --- a/tests/libs/zbxconf/parse_cfg_file.c +++ b/tests/libs/zbxconf/parse_cfg_file.c @@ -79,7 +79,7 @@ void zbx_mock_test_entry(void **state) if (0 == strcmp(tmp, "numeric")) { - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expected", &handle))) + if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expect", &handle))) { expected_values[parameter_count] = NULL; } @@ -99,23 +99,6 @@ void zbx_mock_test_entry(void **state) cfg[parameter_count].variable = zbx_malloc(NULL, sizeof(zbx_uint64_t)); *(zbx_uint64_t *)cfg[parameter_count].variable = (zbx_uint64_t)-1; - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expected", &handle))) - { - expected_values[parameter_count] = NULL; - } - else if (ZBX_MOCK_SUCCESS == error && ZBX_MOCK_SUCCESS == (error = zbx_mock_string(handle, &tmp))) - { - expected_values[parameter_count] = zbx_malloc(NULL, sizeof(zbx_uint64_t)); - - if (SUCCEED != is_uint64(tmp, expected_values[parameter_count])) - { - fail_msg("Expected value \"%s\" of parameter #%d is not numeric.", tmp, - parameter_count + 1); - } - } - else - break; - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "min", &handle))) { cfg[parameter_count].min = 0; @@ -154,7 +137,7 @@ void zbx_mock_test_entry(void **state) } else if (0 == strcmp(tmp, "string")) { - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expected", &handle))) + if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expect", &handle))) { expected_values[parameter_count] = NULL; } @@ -176,7 +159,7 @@ void zbx_mock_test_entry(void **state) { expected_values[parameter_count] = zbx_malloc(NULL, sizeof(zbx_mock_handle_t)); - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expected", + if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expect", expected_values[parameter_count]))) { fail_msg("Missing expected field for parameter #%d of string list type, use [] instead.", @@ -196,7 +179,7 @@ void zbx_mock_test_entry(void **state) { expected_values[parameter_count] = zbx_malloc(NULL, sizeof(zbx_mock_handle_t)); - if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expected", + if (ZBX_MOCK_NO_SUCH_MEMBER == (error = zbx_mock_object_member(parameter, "expect", expected_values[parameter_count]))) { fail_msg("Missing expected field for parameter #%d of multi string type, use [] instead.", @@ -333,7 +316,18 @@ void zbx_mock_test_entry(void **state) } break; case TYPE_STRING: - if (0 != strcmp(*(char **)cfg[i].variable, *(char **)expected_values[i])) + if (NULL == *(char **)cfg[i].variable && NULL != *(char **)expected_values[i]) + { + fail_msg("No value of string parameter \"%s\" while expected \"%s\".", + cfg[i].parameter, *(char **)expected_values[i]); + } + else if (NULL != *(char **)cfg[i].variable && NULL == *(char **)expected_values[i]) + { + fail_msg("Got value \"%s\" of string parameter \"%s\" none was expected.", + *(char **)cfg[i].variable, cfg[i].parameter); + } + else if (NULL != *(char **)cfg[i].variable && NULL != *(char **)expected_values[i] && + 0 != strcmp(*(char **)cfg[i].variable, *(char **)expected_values[i])) { fail_msg("Value \"%s\" of string parameter \"%s\" differs from expected \"%s\".", *(char **)cfg[i].variable, cfg[i].parameter, |