Minor fixes from documentation
authorTom Jackson <tjackson@fb.com>
Wed, 1 Apr 2015 22:22:31 +0000 (15:22 -0700)
committerafrind <afrind@fb.com>
Thu, 2 Apr 2015 19:02:21 +0000 (12:02 -0700)
Test Plan: unittests

Reviewed By: jbrewer@fb.com, ashishsharma@fb.com

Subscribers: maxime, folly-diffs@, yfeldblum, chalfant

FB internal diff: D1956101

Signature: t1:1956101:1427828321:2d828e6f2c06c6dcd6e7baa3ed5e72ee59d9b77f

folly/gen/ParallelMap-inl.h
folly/gen/test/FileTest.cpp

index 0bdadc37b025667a5e76f3f072185f089b5964e2..08ca3f55c14842b36d59c013fd5df275ee591664 100644 (file)
@@ -38,7 +38,7 @@ namespace folly { namespace gen { namespace detail {
  *
  * This type is usually used through the 'pmap' helper function:
  *
- *   auto squares = seq(1, 10) | pmap(4, fibonacci) | sum;
+ *   auto squares = seq(1, 10) | pmap(fibonacci, 4) | sum;
  */
 template<class Predicate>
 class PMap : public Operator<PMap<Predicate>> {
index 38b907fd1af7a9e9212b2b2f18870e768dacd03e..ad70326c93e77765ce9b2bf4875ee546c6625d07 100644 (file)
@@ -69,6 +69,16 @@ TEST_P(FileGenBufferedTest, FileWriter) {
   EXPECT_TRUE(expected == found);
 }
 
+TEST(FileGenBufferedTest, FileWriterSimple) {
+  test::TemporaryFile file("FileWriter");
+  auto toLine = [](int v) { return to<std::string>(v, '\n'); };
+
+  auto squares = seq(1, 100) | map([](int x) { return x * x; });
+  squares | map(toLine) | eachAs<StringPiece>() | toFile(File(file.fd()));
+  EXPECT_EQ(squares | sum,
+            byLine(File(file.path().c_str())) | eachTo<int>() | sum);
+}
+
 INSTANTIATE_TEST_CASE_P(
     DifferentBufferSizes,
     FileGenBufferedTest,