diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
| commit | 6232d13f5321b87ddf12a1aa36b4545da45f173d (patch) | |
| tree | 23f3316470a14136debd9d02f9e920ca2b06f4cc /test/test_htmlutil.cc | |
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in
memroy.
Diffstat (limited to 'test/test_htmlutil.cc')
| -rw-r--r-- | test/test_htmlutil.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_htmlutil.cc b/test/test_htmlutil.cc new file mode 100644 index 0000000..629e646 --- /dev/null +++ b/test/test_htmlutil.cc @@ -0,0 +1,26 @@ +#include "common.hh" + +#include "htmlutil.hh" + +#include <gtest/gtest.h> + +TEST(htmlutil, escape_body) { + EXPECT_EQ("", html::escape("")); + EXPECT_EQ("foo", html::escape("foo")); + EXPECT_EQ("<foo>", html::escape("<foo>")); + EXPECT_EQ("foo & bar", html::escape("foo & bar")); + EXPECT_EQ("\"&lt;\" vs '&gt;'", + html::escape("\"<\" vs '>'")); + EXPECT_EQ("<<<", html::escape("<<<")); +} + +TEST(htmlutil, escape_attribute) { + EXPECT_EQ("", html::escape("", html::EscapeTarget::ATTRIBUTE)); + EXPECT_EQ("foo", html::escape("foo", html::EscapeTarget::ATTRIBUTE)); + EXPECT_EQ("<foo>", html::escape("<foo>", html::EscapeTarget::ATTRIBUTE)); + EXPECT_EQ("foo & bar", html::escape("foo & bar", + html::EscapeTarget::ATTRIBUTE)); + EXPECT_EQ(""&lt;" vs '&gt;'", + html::escape("\"<\" vs '>'", html::EscapeTarget::ATTRIBUTE)); + EXPECT_EQ("<<<", html::escape("<<<", html::EscapeTarget::ATTRIBUTE)); +} |
