summaryrefslogtreecommitdiff
path: root/test/test_jsutil.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /test/test_jsutil.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_jsutil.cc')
-rw-r--r--test/test_jsutil.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_jsutil.cc b/test/test_jsutil.cc
new file mode 100644
index 0000000..8bf3140
--- /dev/null
+++ b/test/test_jsutil.cc
@@ -0,0 +1,15 @@
+#include "common.hh"
+
+#include "jsutil.hh"
+
+#include <gtest/gtest.h>
+
+TEST(jsutil, quote) {
+ EXPECT_EQ("\"\"", js::quote(""));
+ EXPECT_EQ("''", js::quote("", js::QuoteChar::SINGLE));
+ EXPECT_EQ("\"foo\"", js::quote("foo"));
+ EXPECT_EQ("\"\\\"foo\\\"\"", js::quote("\"foo\""));
+ EXPECT_EQ("\"\\\\\\\"foo\\\\\\\"\"", js::quote("\\\"foo\\\""));
+ EXPECT_EQ("\"\\0\\n\\r\\v\\t\\b\\f\"", js::quote(
+ std::string_view("\0\n\r\v\t\b\f", 7)));
+}