Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix overeager assertion

Summary: Also important spelling mistakes.
@override-unit-failures

Test Plan: string_test

Reviewed By: tjackson@fb.com

FB internal diff: D930037
  • Loading branch information...
commit 07ed0a721f66a5333b8ca01cbccc3e2675d97322 1 parent d71636e
@tudor tudor authored sgolemon committed
Showing with 23 additions and 7 deletions.
  1. +1 −1  folly/String-inl.h
  2. +22 −6 folly/test/StringTest.cpp
View
2  folly/String-inl.h
@@ -300,7 +300,7 @@ template<> struct OutputConverter<StringPiece> {
template<class OutStringT, class DelimT, class OutputIterator>
void internalSplit(DelimT delim, StringPiece sp, OutputIterator out,
bool ignoreEmpty) {
- assert(sp.start() != nullptr);
+ assert(sp.empty() || sp.start() != nullptr);
const char* s = sp.start();
const size_t strSize = sp.size();
View
28 folly/test/StringTest.cpp
@@ -481,6 +481,13 @@ void splitTest() {
EXPECT_EQ(parts[2], "c");
parts.clear();
+ folly::split(',', StringPiece("a,b,c"), parts);
+ EXPECT_EQ(parts.size(), 3);
+ EXPECT_EQ(parts[0], "a");
+ EXPECT_EQ(parts[1], "b");
+ EXPECT_EQ(parts[2], "c");
+ parts.clear();
+
folly::split(',', string("a,b,c"), parts);
EXPECT_EQ(parts.size(), 3);
EXPECT_EQ(parts[0], "a");
@@ -559,16 +566,25 @@ void splitTest() {
EXPECT_EQ(parts[0], "");
parts.clear();
+ folly::split("a", StringPiece(), parts, true);
+ EXPECT_EQ(parts.size(), 0);
+ parts.clear();
+
+ folly::split("a", StringPiece(), parts);
+ EXPECT_EQ(parts.size(), 1);
+ EXPECT_EQ(parts[0], "");
+ parts.clear();
+
folly::split("a", "abcdefg", parts, true);
EXPECT_EQ(parts.size(), 1);
EXPECT_EQ(parts[0], "bcdefg");
parts.clear();
- orig = "All, , your bases, are , , belong to us";
+ orig = "All, , your base, are , , belong to us";
folly::split(", ", orig, parts, true);
EXPECT_EQ(parts.size(), 4);
EXPECT_EQ(parts[0], "All");
- EXPECT_EQ(parts[1], "your bases");
+ EXPECT_EQ(parts[1], "your base");
EXPECT_EQ(parts[2], "are ");
EXPECT_EQ(parts[3], "belong to us");
parts.clear();
@@ -576,7 +592,7 @@ void splitTest() {
EXPECT_EQ(parts.size(), 6);
EXPECT_EQ(parts[0], "All");
EXPECT_EQ(parts[1], "");
- EXPECT_EQ(parts[2], "your bases");
+ EXPECT_EQ(parts[2], "your base");
EXPECT_EQ(parts[3], "are ");
EXPECT_EQ(parts[4], "");
EXPECT_EQ(parts[5], "belong to us");
@@ -689,11 +705,11 @@ void piecesTest() {
EXPECT_EQ(pieces[0], "bcdefg");
pieces.clear();
- orig = "All, , your bases, are , , belong to us";
+ orig = "All, , your base, are , , belong to us";
folly::split(", ", orig, pieces, true);
EXPECT_EQ(pieces.size(), 4);
EXPECT_EQ(pieces[0], "All");
- EXPECT_EQ(pieces[1], "your bases");
+ EXPECT_EQ(pieces[1], "your base");
EXPECT_EQ(pieces[2], "are ");
EXPECT_EQ(pieces[3], "belong to us");
pieces.clear();
@@ -701,7 +717,7 @@ void piecesTest() {
EXPECT_EQ(pieces.size(), 6);
EXPECT_EQ(pieces[0], "All");
EXPECT_EQ(pieces[1], "");
- EXPECT_EQ(pieces[2], "your bases");
+ EXPECT_EQ(pieces[2], "your base");
EXPECT_EQ(pieces[3], "are ");
EXPECT_EQ(pieces[4], "");
EXPECT_EQ(pieces[5], "belong to us");
Please sign in to comment.
Something went wrong with that request. Please try again.