Test that QuicTextUtilsTest:Split preserves heading and trailing whitespace.
Chrome's implementation did not use to preserve whitespace until
https://crrev.com/c/1739311, where it was necessary to change it in order to
make QuicFramerTest.TestExtendedErrorCodeParser (introduced at cr/261676212)
pass.
I locally verified that the test passes after merging this change to Chrome.
gfe-relnote: n/a, test-only change.
PiperOrigin-RevId: 262536209
Change-Id: Ibfcb0d6b74e54f00820c7ea8a94f017228019a80
diff --git a/quic/platform/api/quic_text_utils_test.cc b/quic/platform/api/quic_text_utils_test.cc
index 9b156d0..af4e81d 100644
--- a/quic/platform/api/quic_text_utils_test.cc
+++ b/quic/platform/api/quic_text_utils_test.cc
@@ -201,6 +201,11 @@
QuicTextUtils::Split("a:b:c", ':'));
EXPECT_EQ(std::vector<QuicStringPiece>({"a:b:c"}),
QuicTextUtils::Split("a:b:c", ','));
+ // Leading and trailing whitespace is preserved.
+ EXPECT_EQ(std::vector<QuicStringPiece>({"a", "b", "c"}),
+ QuicTextUtils::Split("a,b,c", ','));
+ EXPECT_EQ(std::vector<QuicStringPiece>({" a", "b ", " c "}),
+ QuicTextUtils::Split(" a:b : c ", ':'));
}
} // namespace test