Better support for folly::Range with non-const iterators underneath
[folly.git] / folly / test / RangeTest.cpp
index ee6a0e1bc86989641c427236d9449b1c9272fe5c..faec886660dc15748403aaf86644ceefef7fa7fe 100644 (file)
@@ -908,3 +908,17 @@ TYPED_TEST(NeedleFinderTest, NoSegFault) {
   }
 }
 
+TEST(NonConstTest, StringPiece) {
+  std::string hello("hello");
+  MutableStringPiece sp(&hello.front(), hello.size());
+  sp[0] = 'x';
+  EXPECT_EQ("xello", hello);
+  {
+    StringPiece s(sp);
+    EXPECT_EQ("xello", s);
+  }
+  {
+    ByteRange r1(sp);
+    MutableByteRange r2(sp);
+  }
+}