commit 420725b: [Test] Rework some tests to subcases
Vsevolod Stakhov
vsevolod at highsecure.ru
Sun Jun 20 11:28:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-06-20 12:24:45 +0100
URL: https://github.com/rspamd/rspamd/commit/420725bcd0ce4f580e7aa98a0c7a6b3c8ff49e6d (HEAD -> master)
[Test] Rework some tests to subcases
---
src/libserver/css/css_parser.cxx | 18 +++++++++++-------
src/libserver/css/css_value.cxx | 12 +++++++-----
src/libserver/html/html_entities.cxx | 2 +-
test/rspamd_cxx_unit_utils.hxx | 12 +++++++-----
4 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx
index bac5a72eb..bcff14f75 100644
--- a/src/libserver/css/css_parser.cxx
+++ b/src/libserver/css/css_parser.cxx
@@ -860,17 +860,21 @@ TEST_SUITE("css") {
rspamd_mempool_t *pool = rspamd_mempool_new(rspamd_mempool_suggest_size(),
"css", 0);
for (const auto &c : cases) {
- CHECK(parse_css(pool, c, nullptr).value().get() != nullptr);
+ SUBCASE((std::string("parse css: ") + c).c_str()) {
+ CHECK(parse_css(pool, c, nullptr).value().get() != nullptr);
+ }
}
/* We now merge all styles together */
- std::shared_ptr<css_style_sheet> merged;
- for (const auto &c : cases) {
- auto ret = parse_css(pool, c, std::move(merged));
- merged.swap(ret.value());
- }
+ SUBCASE("merged css parse") {
+ std::shared_ptr<css_style_sheet> merged;
+ for (const auto &c : cases) {
+ auto ret = parse_css(pool, c, std::move(merged));
+ merged.swap(ret.value());
+ }
- CHECK(merged.get() != nullptr);
+ CHECK(merged.get() != nullptr);
+ }
rspamd_mempool_delete(pool);
}
diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx
index 87d6ceb85..6988ea993 100644
--- a/src/libserver/css/css_value.cxx
+++ b/src/libserver/css/css_value.cxx
@@ -388,11 +388,13 @@ TEST_SUITE("css") {
};
for (const auto &p : hex_tests) {
- auto col_parsed = css_value::maybe_color_from_hex(p.first);
- //CHECK_UNARY(col_parsed);
- //CHECK_UNARY(col_parsed.value().to_color());
- auto final_col = col_parsed.value().to_color().value();
- CHECK(final_col == p.second);
+ SUBCASE((std::string("parse hex color: ") + p.first).c_str()) {
+ auto col_parsed = css_value::maybe_color_from_hex(p.first);
+ //CHECK_UNARY(col_parsed);
+ //CHECK_UNARY(col_parsed.value().to_color());
+ auto final_col = col_parsed.value().to_color().value();
+ CHECK(final_col == p.second);
+ }
}
}
TEST_CASE("css colors strings") {
diff --git a/src/libserver/html/html_entities.cxx b/src/libserver/html/html_entities.cxx
index 1d72574b3..2cc3c11f5 100644
--- a/src/libserver/html/html_entities.cxx
+++ b/src/libserver/html/html_entities.cxx
@@ -2578,7 +2578,7 @@ TEST_SUITE("html") {
};
for (const auto &c : cases) {
- SUBCASE(c.first.c_str()) {
+ SUBCASE(("decode entities: " + c.first).c_str()) {
auto *cpy = new char[c.first.size()];
memcpy(cpy, c.first.data(), c.first.size());
auto nlen = decode_html_entitles_inplace(cpy, c.first.size(), true);
diff --git a/test/rspamd_cxx_unit_utils.hxx b/test/rspamd_cxx_unit_utils.hxx
index f5c532ff5..0cd229a4f 100644
--- a/test/rspamd_cxx_unit_utils.hxx
+++ b/test/rspamd_cxx_unit_utils.hxx
@@ -42,11 +42,13 @@ TEST_CASE("rspamd_strip_smtp_comments_inplace") {
};
for (const auto &c : cases) {
- auto *cpy = new char[c.first.size()];
- memcpy(cpy, c.first.data(), c.first.size());
- auto nlen = rspamd_strip_smtp_comments_inplace(cpy, c.first.size());
- CHECK(std::string{cpy,nlen} == c.second);
- delete[] cpy;
+ SUBCASE (("strip comments in " + c.first).c_str()) {
+ auto *cpy = new char[c.first.size()];
+ memcpy(cpy, c.first.data(), c.first.size());
+ auto nlen = rspamd_strip_smtp_comments_inplace(cpy, c.first.size());
+ CHECK(std::string{cpy, nlen} == c.second);
+ delete[] cpy;
+ }
}
}
More information about the Commits
mailing list