From: Richard Russon Date: Tue, 11 Jun 2019 12:13:13 +0000 (+0100) Subject: tests: minor fixes X-Git-Tag: 2019-10-25~166^2~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58f620a84b58abc796471b87486929041faa675e;p=neomutt tests: minor fixes Fix: - Misleading output - printf specifiers - Missing test cases --- diff --git a/test/config/common.c b/test/config/common.c index f7e8dcc57..2c7a94706 100644 --- a/test/config/common.c +++ b/test/config/common.c @@ -98,13 +98,13 @@ int log_observer(struct NotifyCallback *nc) mutt_buffer_reset(&result); - if (nc->event_type != NT_CONFIG_INITIAL_SET) + if (nc->event_subtype != NT_CONFIG_INITIAL_SET) cs_he_string_get(ec->cs, ec->he, &result); else cs_he_initial_get(ec->cs, ec->he, &result); TEST_MSG("Event: %s has been %s to '%s'\n", ec->name, - events[nc->event_type - 1], result.data); + events[nc->event_subtype - 1], result.data); FREE(&result.data); return true; diff --git a/test/config/long.c b/test/config/long.c index 875378fd0..d3764c887 100644 --- a/test/config/long.c +++ b/test/config/long.c @@ -78,13 +78,13 @@ static bool test_initial_values(struct ConfigSet *cs, struct Buffer *err) if (!TEST_CHECK(VarApple == -42)) { TEST_MSG("Expected: %d\n", -42); - TEST_MSG("Actual : %d\n", VarApple); + TEST_MSG("Actual : %ld\n", VarApple); } if (!TEST_CHECK(VarBanana == 99)) { TEST_MSG("Expected: %d\n", 99); - TEST_MSG("Actual : %d\n", VarBanana); + TEST_MSG("Actual : %ld\n", VarBanana); } cs_str_string_set(cs, "Apple", "2001", err); @@ -205,7 +205,7 @@ static bool test_string_set(struct ConfigSet *cs, struct Buffer *err) rc = cs_str_string_set(cs, name, invalid[i], err); if (!TEST_CHECK(CSR_RESULT(rc) != CSR_SUCCESS)) { - TEST_MSG("%s = %d, set by '%s'\n", name, VarDamson, NONULL(invalid[i])); + TEST_MSG("%s = %ld, set by '%s'\n", name, VarDamson, NONULL(invalid[i])); TEST_MSG("This test should have failed\n"); return false; } @@ -269,7 +269,7 @@ static bool test_native_set(struct ConfigSet *cs, struct Buffer *err) const char *name = "Guava"; long value = 12345; - TEST_MSG("Setting %s to %d\n", name, value); + TEST_MSG("Setting %s to %ld\n", name, value); VarGuava = 0; mutt_buffer_reset(err); int rc = cs_str_native_set(cs, name, value, err); @@ -288,7 +288,7 @@ static bool test_native_set(struct ConfigSet *cs, struct Buffer *err) TEST_MSG("%s = %ld, set to '%ld'\n", name, VarGuava, value); short_line(); - TEST_MSG("Setting %s to %d\n", name, value); + TEST_MSG("Setting %s to %ld\n", name, value); rc = cs_str_native_set(cs, name, value, err); if (!TEST_CHECK((rc & CSR_SUC_NO_CHANGE) != 0)) { @@ -303,7 +303,7 @@ static bool test_native_set(struct ConfigSet *cs, struct Buffer *err) name = "Hawthorn"; value = -42; short_line(); - TEST_MSG("Setting %s to %d\n", name, value); + TEST_MSG("Setting %s to %ld\n", name, value); rc = cs_str_native_set(cs, name, value, err); if (TEST_CHECK(CSR_RESULT(rc) != CSR_SUCCESS)) { @@ -346,7 +346,7 @@ static bool test_reset(struct ConfigSet *cs, struct Buffer *err) VarJackfruit = 345; mutt_buffer_reset(err); - TEST_MSG("%s = %d\n", name, VarJackfruit); + TEST_MSG("%s = %ld\n", name, VarJackfruit); int rc = cs_str_reset(cs, name, err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS)) { @@ -366,7 +366,7 @@ static bool test_reset(struct ConfigSet *cs, struct Buffer *err) name = "Kumquat"; mutt_buffer_reset(err); - TEST_MSG("Initial: %s = %d\n", name, VarKumquat); + TEST_MSG("Initial: %s = %ld\n", name, VarKumquat); dont_fail = true; rc = cs_str_string_set(cs, name, "99", err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS)) diff --git a/test/config/number.c b/test/config/number.c index bf3cdd5c4..9b65a2e41 100644 --- a/test/config/number.c +++ b/test/config/number.c @@ -498,6 +498,22 @@ static bool test_validator(struct ConfigSet *cs, struct Buffer *err) TEST_MSG("String: %s = %d\n", name, VarNectarine); short_line(); + struct HashElem *he = cs_get_elem(cs, name); + VarNectarine = 123; + mutt_buffer_reset(err); + rc = cs_he_native_set(cs, he, 456, err); + if (TEST_CHECK(CSR_RESULT(rc) != CSR_SUCCESS)) + { + TEST_MSG("Expected error: %s\n", err->data); + } + else + { + TEST_MSG("%s\n", err->data); + return false; + } + TEST_MSG("String: %s = %d\n", name, VarNectarine); + short_line(); + VarNectarine = 456; mutt_buffer_reset(err); rc = cs_str_native_set(cs, name, 123, err);