add equals interface for Range class.
[folly.git] / folly / test / ShellTest.cpp
index 00ddc043a5bab35686b3026db02f127e054b5cb2..697ecd8e05154aead8b0894751ce4b136dc23db1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
  */
 
 #include <glog/logging.h>
-#include <gtest/gtest.h>
 
 #include <folly/Shell.h>
+#include <folly/portability/GTest.h>
 
 using namespace folly;
 
@@ -28,6 +28,22 @@ TEST(Shell, ShellQuote) {
 }
 
 TEST(Shell, Shellify) {
+  auto command = "rm -rf /"_shellify();
+  EXPECT_EQ(command[0], "/bin/sh");
+  EXPECT_EQ(command[1], "-c");
+  EXPECT_EQ(command[2], "rm -rf /");
+
+  command = "rm -rf {}"_shellify("someFile.txt");
+  EXPECT_EQ(command[2], "rm -rf 'someFile.txt'");
+
+  command = "rm -rf {}"_shellify(5);
+  EXPECT_EQ(command[2], "rm -rf '5'");
+
+  command = "ls {}"_shellify("blah'; rm -rf /");
+  EXPECT_EQ(command[2], "ls 'blah'\\''; rm -rf /'");
+}
+
+TEST(Shell, Shellify_deprecated) {
   auto command = shellify("rm -rf /");
   EXPECT_EQ(command[0], "/bin/sh");
   EXPECT_EQ(command[1], "-c");