Browse Source

[Test] Rework some tests to subcases

tags/3.0
Vsevolod Stakhov 3 years ago
parent
commit
420725bcd0

+ 11
- 7
src/libserver/css/css_parser.cxx View 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);
}

+ 7
- 5
src/libserver/css/css_value.cxx View 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") {

+ 1
- 1
src/libserver/html/html_entities.cxx View 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);

+ 7
- 5
test/rspamd_cxx_unit_utils.hxx View 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;
}
}
}


Loading…
Cancel
Save