Commit 60f2c87d authored by Peter Griess's avatar Peter Griess Committed by Sara Golemon

Only run FBString.testConstructionFromLiteralZero under GNU libstdc++

Summary:
- This test verifies the behavior of std::string(0), which the GNU
library expects to throw an std::logic_error. Other libraries may have
other behaviors; libc++ segfaults.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: simpkins@fb.com

FB internal diff: D1003125
parent 9d456e4f
...@@ -1082,22 +1082,14 @@ TEST(FBString, testMoveOperatorPlusRhs) { ...@@ -1082,22 +1082,14 @@ TEST(FBString, testMoveOperatorPlusRhs) {
EXPECT_EQ(size1 + size2, test.size()); EXPECT_EQ(size1 + size2, test.size());
} }
// The GNU C++ standard library throws an std::logic_error when an std::string
// is constructed with a null pointer. Verify that we mirror this behavior.
//
// N.B. We behave this way even if the C++ library being used is something
// other than libstdc++. Someday if we deem it important to present
// identical undefined behavior for other platforms, we can re-visit this.
TEST(FBString, testConstructionFromLiteralZero) { TEST(FBString, testConstructionFromLiteralZero) {
try { EXPECT_THROW(fbstring s(0), std::logic_error);
std::string s(0);
EXPECT_TRUE(false);
} catch (const std::logic_error&) {
} catch (...) {
EXPECT_TRUE(false);
}
try {
fbstring s(0);
EXPECT_TRUE(false);
} catch (const std::logic_error& e) {
} catch (...) {
EXPECT_TRUE(false);
}
} }
TEST(FBString, testFixedBugs) { TEST(FBString, testFixedBugs) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment