]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Rework some tests to subcases
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Jun 2021 11:24:45 +0000 (12:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Jun 2021 11:24:45 +0000 (12:24 +0100)
src/libserver/css/css_parser.cxx
src/libserver/css/css_value.cxx
src/libserver/html/html_entities.cxx
test/rspamd_cxx_unit_utils.hxx

index bac5a72ebc3868e36bef3e54657ff858f80f6735..bcff14f75084cf34dd359b3bb7b90f02e6bf1472 100644 (file)
@@ -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);
        }
index 87d6ceb85efc2bff55e033195d94af219914421f..6988ea993d32bc370224d7e629900fb45f4b1d95 100644 (file)
@@ -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") {
index 1d72574b367390c8108f3221cfe790ae03c6fe2c..2cc3c11f56356ba16cb7a6eca500c43a29dbc288 100644 (file)
@@ -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);
index f5c532ff55e6a03b9f35eccf113670df6b47f0e3..0cd229a4fc354a1aa610740b4b27856b37e7bb02 100644 (file)
@@ -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;
+               }
        }
 }