commit 447755d: [Test] Slightly reorganize tests
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Jun 18 19:42:08 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-06-18 20:35:05 +0100
URL: https://github.com/rspamd/rspamd/commit/447755d6c8951bdf9593dab9593dac368bcaa372 (HEAD -> master)
[Test] Slightly reorganize tests
---
src/libserver/css/css_parser.cxx | 2 +-
src/libserver/css/css_rule.cxx | 2 +-
src/libserver/css/css_selector.cxx | 2 +-
src/libserver/css/css_value.cxx | 2 +-
src/libserver/html/html.cxx | 19 +++++++++++--------
test/rspamd_cxx_unit_utils.hxx | 1 +
6 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx
index 6943e1cf6..bac5a72eb 100644
--- a/src/libserver/css/css_parser.cxx
+++ b/src/libserver/css/css_parser.cxx
@@ -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 тест */",
diff --git a/src/libserver/css/css_rule.cxx b/src/libserver/css/css_rule.cxx
index 52003ac23..d8c3a04dd 100644
--- a/src/libserver/css/css_rule.cxx
+++ b/src/libserver/css/css_rule.cxx
@@ -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{
{
diff --git a/src/libserver/css/css_selector.cxx b/src/libserver/css/css_selector.cxx
index a4e1eb566..28b64a9fd 100644
--- a/src/libserver/css/css_selector.cxx
+++ b/src/libserver/css/css_selector.cxx
@@ -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}},
diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx
index d187f1031..87d6ceb85 100644
--- a/src/libserver/css/css_value.cxx
+++ b/src/libserver/css/css_value.cxx
@@ -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)},
diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index bb6d8b725..073b733a2 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -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);
}
+}
}
diff --git a/test/rspamd_cxx_unit_utils.hxx b/test/rspamd_cxx_unit_utils.hxx
index a65adab70..f5c532ff5 100644
--- a/test/rspamd_cxx_unit_utils.hxx
+++ b/test/rspamd_cxx_unit_utils.hxx
@@ -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;
}
}
More information about the Commits
mailing list