X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FStringTest.cpp;h=727b6933bc91b0776a42817ce1116b67d473c751;hb=717229ecf385ee10a91d6c2af859e8550df84531;hp=76cf6ac40f78c0bdd8d300ed2dff5e98e945b02c;hpb=ad2f228ab1359952d37acdc4f3032e1405cca221;p=folly.git diff --git a/folly/test/StringTest.cpp b/folly/test/StringTest.cpp index 76cf6ac4..727b6933 100644 --- a/folly/test/StringTest.cpp +++ b/folly/test/StringTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2012-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,18 @@ * limitations under the License. */ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS 1 +#endif + #include +#include + #include -#include -#include +#include +#include using namespace folly; using namespace std; @@ -218,7 +224,7 @@ void expectPrintable(StringPiece s) { EXPECT_GE(127, c); } } -} // namespace +} // namespace TEST(Escape, uriEscapeAllCombinations) { char c[3]; @@ -246,7 +252,7 @@ bool isHex(int v) { (v >= 'A' && v <= 'F') || (v >= 'a' && v <= 'f')); } -} // namespace +} // namespace TEST(Escape, uriUnescapePercentDecoding) { char c[4] = {'%', '\0', '\0', '\0'}; @@ -277,7 +283,7 @@ double pow2(int exponent) { return double(int64_t(1) << exponent); } -} // namespace +} // namespace struct PrettyTestCase{ std::string prettyString; double realValue; @@ -414,7 +420,7 @@ TEST(PrettyToDouble, Basic) { try{ recoveredX = prettyToDouble(testString, formatType); } catch (const std::range_error& ex) { - EXPECT_TRUE(false) << testCase.prettyString << " -> " << ex.what(); + ADD_FAILURE() << testCase.prettyString << " -> " << ex.what(); } double relativeError = fabs(x) < 1e-5 ? (x-recoveredX) : (x - recoveredX) / x; @@ -431,8 +437,8 @@ TEST(PrettyToDouble, Basic) { try{ recoveredX = prettyToDouble(prettyPrint(x, formatType, addSpace), formatType); - } catch (std::range_error &ex){ - EXPECT_TRUE(false); + } catch (std::range_error&) { + ADD_FAILURE(); } double relativeError = (x - recoveredX) / x; EXPECT_NEAR(0, relativeError, 1e-3); @@ -487,7 +493,7 @@ TEST(System, errnoStr) { namespace { -template class VectorType> +template