Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
51 lines
2.0 KiB
C++
51 lines
2.0 KiB
C++
|
|
#include <mln/style/expression/formatted.hpp>
|
|
#include <mln/test/util.hpp>
|
|
|
|
using namespace mln;
|
|
using namespace mln::style::expression;
|
|
|
|
TEST(Formatted, Equality) {
|
|
Formatted text{"Formatted"};
|
|
auto emptyImage = FormattedSection{style::expression::Image("Formatted")};
|
|
Formatted image{std::vector<FormattedSection>{emptyImage}};
|
|
EXPECT_FALSE(text == image);
|
|
EXPECT_EQ(text, text);
|
|
EXPECT_EQ(image, image);
|
|
}
|
|
|
|
TEST(Formatted, Empty) {
|
|
Formatted emptyFormatted{""};
|
|
EXPECT_TRUE(emptyFormatted.empty());
|
|
|
|
auto emptyText = FormattedSection{"", std::nullopt, std::nullopt, std::nullopt};
|
|
auto emptyImage = FormattedSection{style::expression::Image()};
|
|
Formatted multipleEmptySections{std::vector<FormattedSection>{emptyText, emptyText, emptyText}};
|
|
EXPECT_TRUE(multipleEmptySections.empty());
|
|
|
|
Formatted multipleEmptySectionsWithImage{std::vector<FormattedSection>{emptyText, emptyImage, emptyText}};
|
|
EXPECT_TRUE(multipleEmptySectionsWithImage.empty());
|
|
|
|
auto text = FormattedSection{"Formatted", std::nullopt, std::nullopt, std::nullopt};
|
|
auto image = FormattedSection{style::expression::Image("Image")};
|
|
|
|
Formatted multipleSections{std::vector<FormattedSection>{emptyText, text, emptyText}};
|
|
EXPECT_FALSE(multipleSections.empty());
|
|
|
|
Formatted multipleSectionsWithImage{std::vector<FormattedSection>{emptyText, image, text}};
|
|
EXPECT_FALSE(multipleSectionsWithImage.empty());
|
|
}
|
|
|
|
TEST(Formatted, ToString) {
|
|
Formatted emptyFormatted{""};
|
|
EXPECT_EQ(emptyFormatted.toString(), "");
|
|
|
|
auto text = FormattedSection{"Formatted", std::nullopt, std::nullopt, std::nullopt};
|
|
Formatted multipleSections{std::vector<FormattedSection>{text, text}};
|
|
EXPECT_EQ(multipleSections.toString(), "FormattedFormatted");
|
|
|
|
auto image = FormattedSection{style::expression::Image("Image")};
|
|
Formatted multipleEmptySectionsWithImage{std::vector<FormattedSection>{text, image}};
|
|
EXPECT_EQ(multipleEmptySectionsWithImage.toString(), "Formatted");
|
|
}
|