From: Chad Austin Date: Mon, 8 Jan 2018 19:12:18 +0000 (-0800) Subject: test that _sp includes nul bytes X-Git-Tag: v2018.01.15.00~42 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=3df176287c46e280f8d4be3b8dc1674fef8cdeb7 test that _sp includes nul bytes Summary: D6617812 wants to build a StringPiece from a literal with an embedded nul. Add a test to verify that _sp is suitable for this use case. Reviewed By: yfeldblum Differential Revision: D6651024 fbshipit-source-id: be4fb875762829fdb61c57fa72954fef286e9df0 --- diff --git a/folly/test/RangeTest.cpp b/folly/test/RangeTest.cpp index b1298cac..42faf4de 100644 --- a/folly/test/RangeTest.cpp +++ b/folly/test/RangeTest.cpp @@ -1428,3 +1428,8 @@ TEST(Range, LiteralSuffix) { constexpr Range pieceW{L"hello", 5}; EXPECT_EQ(literalPieceW, pieceW); } + +TEST(Range, LiteralSuffixContainsNulBytes) { + constexpr auto literalPiece = "\0foo\0"_sp; + EXPECT_EQ(5u, literalPiece.size()); +}