Commit 7f0c4bda authored by Hans Fugal's avatar Hans Fugal Committed by Viswanath Sivakumar

(folly) Account for different vsnprintf behavior on OSX in test

Summary: Apparently there is some dispute about the correct thing for `snprintf(buf, len, "bogus%", "foo")` to return. OSX says 5, Linux says -1. The code in `folly/String.cpp` depends on -1 to throw the exception this test was expecting.

Test Plan: make check on OSX

Reviewed By: chip@fb.com

Subscribers: exa, folly-diffs@

FB internal diff: D1770970

Tasks: 5936226

Signature: t1:1770970:1420680750:bafae2aa8327a52013e68af64a163323244ca03b
parent 6d079c14
......@@ -99,8 +99,13 @@ void vprintfError(const char* fmt, ...) {
va_end(ap);
};
// OSX's sprintf family does not return a negative number on a bad format
// string, but Linux does. It's unclear to me which behavior is more
// correct.
#if !__APPLE__
EXPECT_THROW({stringVPrintf(fmt, ap);},
std::runtime_error);
#endif
}
TEST(StringPrintf, VPrintf) {
......
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