From: Vsevolod Stakhov Date: Fri, 15 Apr 2022 20:42:39 +0000 (+0100) Subject: [Test] Properly set test cases X-Git-Tag: 3.3~309 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1727d1df984ffadaa696d5057e54635f25304fd5;p=thirdparty%2Frspamd.git [Test] Properly set test cases --- diff --git a/test/rspamd_cxx_unit_dkim.hxx b/test/rspamd_cxx_unit_dkim.hxx index 802e9ecbfe..79556a58e2 100644 --- a/test/rspamd_cxx_unit_dkim.hxx +++ b/test/rspamd_cxx_unit_dkim.hxx @@ -21,7 +21,7 @@ #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL #include "doctest/doctest.h" - +#include "fmt/core.h" #include "libserver/dkim.h" #include @@ -142,23 +142,23 @@ TEST_CASE("rspamd_dkim_parse_key") false, ""}, }; + auto cur_test_idx = 0; for (auto &&c : cases) { - SUBCASE (("process DKIM record " + c.input).c_str()) { + SUBCASE (fmt::format("process DKIM record {}: {}", cur_test_idx++, c.input).c_str()) { + GError *err = nullptr; gsize klen = c.input.size(); - auto *key = rspamd_dkim_parse_key(c.input.c_str(), &klen, nullptr); + auto *key = rspamd_dkim_parse_key(c.input.c_str(), &klen, &err); if (c.is_valid) { - CHECK(key != nullptr); + REQUIRE_MESSAGE(key != nullptr, (err ? err->message : "unknown error")); char hexbuf[RSPAMD_DKIM_KEY_ID_LEN * 2 + 1]; auto *id = rspamd_dkim_key_id(key); - CHECK(id != nullptr); + REQUIRE(id != nullptr); - if (id) { - auto hexlen = rspamd_encode_hex_buf(id, RSPAMD_DKIM_KEY_ID_LEN, hexbuf, - sizeof(hexbuf)); - CHECK(hexlen > 0); - CHECK(std::string{hexbuf, (std::size_t) hexlen} == c.expected_id); - rspamd_dkim_key_free(key); - } + auto hexlen = rspamd_encode_hex_buf(id, RSPAMD_DKIM_KEY_ID_LEN, hexbuf, + sizeof(hexbuf)); + CHECK(hexlen > 0); + CHECK(std::string{hexbuf, (std::size_t) hexlen} == c.expected_id); + rspamd_dkim_key_free(key); } else { CHECK(key == nullptr);