aboutsummaryrefslogtreecommitdiffstats
path: root/test/rspamd_cxx_unit_dkim.hxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-04-15 21:42:39 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-04-15 21:42:39 +0100
commit1727d1df984ffadaa696d5057e54635f25304fd5 (patch)
tree8c13a86e994a45f31ef68be89c95be8f7cfc5b33 /test/rspamd_cxx_unit_dkim.hxx
parent58ed7953ef439d242c4822f837ed745c6869f761 (diff)
downloadrspamd-1727d1df984ffadaa696d5057e54635f25304fd5.tar.gz
rspamd-1727d1df984ffadaa696d5057e54635f25304fd5.zip
[Test] Properly set test cases
Diffstat (limited to 'test/rspamd_cxx_unit_dkim.hxx')
-rw-r--r--test/rspamd_cxx_unit_dkim.hxx24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/rspamd_cxx_unit_dkim.hxx b/test/rspamd_cxx_unit_dkim.hxx
index 802e9ecbf..79556a58e 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 <vector>
@@ -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);