Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / gn / escape_unittest.cc
index a637e87..7ba0af0 100644 (file)
@@ -5,6 +5,26 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "tools/gn/escape.h"
 
+TEST(Escape, Ninja) {
+  EscapeOptions opts;
+  opts.mode = ESCAPE_NINJA;
+  std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
+  EXPECT_EQ("asdf$:$ \"$$\\bar", result);
+}
+
+TEST(Escape, Shell) {
+  EscapeOptions opts;
+  opts.mode = ESCAPE_SHELL;
+  std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
+#if defined(OS_WIN)
+  // Windows shell doesn't escape backslashes, but it does backslash-escape
+  // quotes.
+  EXPECT_EQ("\"asdf: \\\"$\\bar\"", result);
+#else
+  EXPECT_EQ("\"asdf: \\\"$\\\\bar\"", result);
+#endif
+}
+
 TEST(Escape, UsedQuotes) {
   EscapeOptions shell_options;
   shell_options.mode = ESCAPE_SHELL;