Codemod: use #include angle brackets in folly and thrift
[folly.git] / folly / gen / test / StringTest.cpp
index 17fb9c09d7e5573a57a0cbf71f5afca42bc7f178..71acab88418bdd696e96d5d1aa7eb15374056033 100644 (file)
@@ -20,7 +20,7 @@
 #include <map>
 #include <vector>
 
-#include "folly/gen/String.h"
+#include <folly/gen/String.h>
 
 using namespace folly::gen;
 using namespace folly;
@@ -82,13 +82,36 @@ TEST(StringGen, Split) {
   }
 
   {
-    auto pieces = split("hello,, world, goodbye, meow", ',')
+    auto pieces = split("hello,, world, goodbye, meow", ",")
                 | take(5) | collect;
     EXPECT_EQ(5, pieces.size());
     EXPECT_EQ("hello", pieces[0]);
     EXPECT_EQ("", pieces[1]);
     EXPECT_EQ(" world", pieces[2]);
   }
+
+  {
+    auto pieces = split("hello,, world, goodbye, meow", ", ")
+                | collect;
+    EXPECT_EQ(4, pieces.size());
+    EXPECT_EQ("hello,", pieces[0]);
+    EXPECT_EQ("world", pieces[1]);
+    EXPECT_EQ("goodbye", pieces[2]);
+    EXPECT_EQ("meow", pieces[3]);
+  }
+}
+
+TEST(StringGen, SplitByNewLine) {
+  auto collect = eachTo<std::string>() | as<vector>();
+  {
+    auto pieces = lines("hello\n\n world\r\n goodbye\r meow") | collect;
+    EXPECT_EQ(5, pieces.size());
+    EXPECT_EQ("hello", pieces[0]);
+    EXPECT_EQ("", pieces[1]);
+    EXPECT_EQ(" world", pieces[2]);
+    EXPECT_EQ(" goodbye", pieces[3]);
+    EXPECT_EQ(" meow", pieces[4]);
+  }
 }
 
 TEST(StringGen, EmptyResplit) {