]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Slightly reorganize tests
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Jun 2021 19:35:05 +0000 (20:35 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Jun 2021 19:35:24 +0000 (20:35 +0100)
src/libserver/css/css_parser.cxx
src/libserver/css/css_rule.cxx
src/libserver/css/css_selector.cxx
src/libserver/css/css_value.cxx
src/libserver/html/html.cxx
test/rspamd_cxx_unit_utils.hxx

index 6943e1cf62d1d08404c66c7b6d187331e44e00eb..bac5a72ebc3868e36bef3e54657ff858f80f6735 100644 (file)
@@ -817,7 +817,7 @@ parse_css_declaration(rspamd_mempool_t *pool, const std::string_view &st)
        return nullptr;
 }
 
-TEST_SUITE("css parser") {
+TEST_SUITE("css") {
        TEST_CASE("parse colors") {
                const std::vector<const char *> cases{
                        "P { CoLoR: rgb(100%, 50%, 0%); opacity: -1; width: 1em; display: none; } /* very transparent solid orange ั‚ะตัั‚ */",
index 52003ac236759d3785fc52ed5d27eb6dc832e29d..d8c3a04ddf3b8012935d9b89c130059a91a5b361 100644 (file)
@@ -500,7 +500,7 @@ void css_rule::add_value(const css_value &value)
 }
 
 
-TEST_SUITE("css rules") {
+TEST_SUITE("css") {
        TEST_CASE("simple css rules") {
                const std::vector<std::pair<const char *, std::vector<css_property>>> cases{
                                {
index a4e1eb566ec1ecc01cb560e2db8f49f4516b1a96..28b64a9fde383e515e7b60c149ddc154ba3979f7 100644 (file)
@@ -191,7 +191,7 @@ css_selector::debug_str() const -> std::string
        return ret;
 }
 
-TEST_SUITE("css selectors") {
+TEST_SUITE("css") {
        TEST_CASE("simple css selectors") {
                const std::vector<std::pair<const char *, std::vector<css_selector::selector_type>>> cases{
                                {"em", {css_selector::selector_type::SELECTOR_TAG}},
index d187f10310aaf8eec594494534f5252deff7dbff..87d6ceb85efc2bff55e033195d94af219914421f 100644 (file)
@@ -377,7 +377,7 @@ auto css_value::debug_str() const -> std::string {
        return ret;
 }
 
-TEST_SUITE("css values") {
+TEST_SUITE("css") {
        TEST_CASE("css hex colors") {
                const std::pair<const char*, css_color> hex_tests[] = {
                                {"000", css_color(0, 0, 0)},
index bb6d8b72529dd957c8c00e86b4f03cd34c377226..073b733a209cad9f35dd13542a6ebcc5d1740628 100644 (file)
@@ -1796,17 +1796,19 @@ auto html_tag_by_name(const std::string_view &name)
  * Tests part
  */
 
-TEST_CASE("html parsing") {
+TEST_SUITE("html") {
+TEST_CASE("html parsing")
+{
 
        const std::vector<std::pair<std::string, std::string>> cases{
-                       {"<html><!DOCTYPE html><body>", "+html;++body;"},
-                       {"<html><div><div></div></div></html>", "+html;++div;+++div;"},
-                       {"<html><div><div></div></html>", "+html;++div;+++div;"},
-                       {"<html><div><div></div></html></div>", "+html;++div;+++div;"},
-                       {"<p><p><a></p></a></a>", "+p;++p;+++a;"},
+                       {"<html><!DOCTYPE html><body>",                    "+html;++body;"},
+                       {"<html><div><div></div></div></html>",            "+html;++div;+++div;"},
+                       {"<html><div><div></div></html>",                  "+html;++div;+++div;"},
+                       {"<html><div><div></div></html></div>",            "+html;++div;+++div;"},
+                       {"<p><p><a></p></a></a>",                          "+p;++p;+++a;"},
                        {"<div><a href=\"http://example.com\"></div></a>", "+div;++a;"},
                        {"<html><!DOCTYPE html><body><head><body></body></html></body></html>",
-                                       "+html;++body;+++head;++++body;"}
+                                                                                                                          "+html;++body;+++head;++++body;"}
        };
 
        rspamd_url_init(NULL);
@@ -1815,7 +1817,7 @@ TEST_CASE("html parsing") {
 
        for (const auto &c : cases) {
                GByteArray *tmp = g_byte_array_sized_new(c.first.size());
-               g_byte_array_append(tmp, (const guint8 *)c.first.data(), c.first.size());
+               g_byte_array_append(tmp, (const guint8 *) c.first.data(), c.first.size());
                auto *hc = html_process_input(pool, tmp, nullptr, nullptr, nullptr, true);
                CHECK(hc != nullptr);
                auto dump = html_debug_structure(*hc);
@@ -1825,6 +1827,7 @@ TEST_CASE("html parsing") {
 
        rspamd_mempool_delete(pool);
 }
+}
 
 }
 
index a65adab7016156507bd8fb12047091a909a67c5b..f5c532ff55e6a03b9f35eccf113670df6b47f0e3 100644 (file)
@@ -46,6 +46,7 @@ TEST_CASE("rspamd_strip_smtp_comments_inplace") {
                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;
        }
 }