diff options
Diffstat (limited to 'test/test-htmlattrtext.cc')
| -rw-r--r-- | test/test-htmlattrtext.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test-htmlattrtext.cc b/test/test-htmlattrtext.cc new file mode 100644 index 0000000..a0d18e6 --- /dev/null +++ b/test/test-htmlattrtext.cc @@ -0,0 +1,38 @@ +// -*- mode: c++; c-basic-offset: 2; -*- + +#include "common.hh" +#include "test.hh" + +#include <memory> + +#include "gui_htmlattrtext.hh" + +namespace { + +bool test_sanity() { + std::unique_ptr<HtmlAttributedText> attr(HtmlAttributedText::create()); + HtmlAttributedText::Attribute red(0xff, 0, 0); + HtmlAttributedText::Attribute bold; + HtmlAttributedText::Attribute green(0, 0xff, 0); + bold.set_bold(true); + ASSERT_EQ("", attr->html()); + attr->append("Hello World"); + ASSERT_EQ("Hello World", attr->html()); + attr->append(" <!>", red); + ASSERT_EQ("Hello World<span style=\"color: rgb(255, 0, 0); \"> <!></span>", attr->html()); + attr->add(bold, 0, 5); + ASSERT_EQ("<span style=\"font-weight: bold; \">Hello</span> World<span style=\"color: rgb(255, 0, 0); \"> <!></span>", attr->html()); + attr->add(red, 1, 2); + ASSERT_EQ("<span style=\"font-weight: bold; \">H<span style=\"color: rgb(255, 0, 0); \">el</span>lo</span> World<span style=\"color: rgb(255, 0, 0); \"> <!></span>", attr->html()); + attr->set(green, 1, 1); + ASSERT_EQ("<span style=\"font-weight: bold; \">H</span><span style=\"color: rgb(0, 255, 0); \">e</span><span style=\"font-weight: bold; \"><span style=\"color: rgb(255, 0, 0); \">l</span>lo</span> World<span style=\"color: rgb(255, 0, 0); \"> <!></span>", attr->html()); + return true; +} + +} // namespace + +int main(void) { + BEFORE; + RUN(test_sanity()); + AFTER; +} |
