X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FFBStringTest.cpp;h=9f51947af6c855bc88f92f749818712523b18cbf;hb=db13010c1338d471c713a652e0940afba627b8bc;hp=92f32eb362d6646c9da2cb1cd2029a663569da3a;hpb=520e20a8baebc98a5ec84d67865da4cf9819f88a;p=folly.git diff --git a/folly/test/FBStringTest.cpp b/folly/test/FBStringTest.cpp index 92f32eb3..9f51947a 100644 --- a/folly/test/FBStringTest.cpp +++ b/folly/test/FBStringTest.cpp @@ -29,9 +29,9 @@ #include #include -#include #include #include +#include #include using namespace std; @@ -75,7 +75,7 @@ std::list RandomList(unsigned int maxSize) { } return lst; } -} +} // namespace //////////////////////////////////////////////////////////////////////////////// // Tests begin here @@ -143,12 +143,16 @@ template void clause11_21_4_2_h(String & test) { EXPECT_EQ(test, s2); // Constructor from other iterators std::list lst; - for (auto c : test) lst.push_back(c); + for (auto c : test) { + lst.push_back(c); + } String s3(lst.begin(), lst.end()); EXPECT_EQ(test, s3); // Constructor from wchar_t iterators std::list lst1; - for (auto c : test) lst1.push_back(c); + for (auto c : test) { + lst1.push_back(c); + } String s4(lst1.begin(), lst1.end()); EXPECT_EQ(test, s4); // Constructor from wchar_t pointers @@ -249,8 +253,11 @@ template void clause11_21_4_4(String & test) { // exercise empty string empty("empty"); string notempty("not empty"); - if (test.empty()) test = String(empty.begin(), empty.end()); - else test = String(notempty.begin(), notempty.end()); + if (test.empty()) { + test = String(empty.begin(), empty.end()); + } else { + test = String(notempty.begin(), notempty.end()); + } } template void clause11_21_4_5(String & test) { @@ -828,8 +835,11 @@ template void clause11_21_4_7_9_a(String & test) { String s; randomString(&s, maxString); int tristate = test.compare(s); - if (tristate > 0) tristate = 1; - else if (tristate < 0) tristate = 2; + if (tristate > 0) { + tristate = 1; + } else if (tristate < 0) { + tristate = 2; + } Num2String(test, tristate); } @@ -840,8 +850,11 @@ template void clause11_21_4_7_9_b(String & test) { random(0, test.size()), random(0, test.size()), s); - if (tristate > 0) tristate = 1; - else if (tristate < 0) tristate = 2; + if (tristate > 0) { + tristate = 1; + } else if (tristate < 0) { + tristate = 2; + } Num2String(test, tristate); } @@ -854,8 +867,11 @@ template void clause11_21_4_7_9_c(String & test) { str, random(0, str.size()), random(0, str.size())); - if (tristate > 0) tristate = 1; - else if (tristate < 0) tristate = 2; + if (tristate > 0) { + tristate = 1; + } else if (tristate < 0) { + tristate = 2; + } Num2String(test, tristate); } @@ -863,9 +879,12 @@ template void clause11_21_4_7_9_d(String & test) { String s; randomString(&s, maxString); int tristate = test.compare(s.c_str()); - if (tristate > 0) tristate = 1; - else if (tristate < 0) tristate = 2; - Num2String(test, tristate); + if (tristate > 0) { + tristate = 1; + } else if (tristate < 0) { + tristate = 2; + } + Num2String(test, tristate); } template void clause11_21_4_7_9_e(String & test) { @@ -876,8 +895,11 @@ template void clause11_21_4_7_9_e(String & test) { random(0, test.size()), str.c_str(), random(0, str.size())); - if (tristate > 0) tristate = 1; - else if (tristate < 0) tristate = 2; + if (tristate > 0) { + tristate = 1; + } else if (tristate < 0) { + tristate = 2; + } Num2String(test, tristate); } @@ -996,7 +1018,10 @@ TEST(FBString, testAllClauses) { void(*f_fbstring)(folly::fbstring&), void(*f_wfbstring)(folly::basic_fbstring&)) { do { - if (1) {} else EXPECT_TRUE(1) << "Testing clause " << clause; + if (true) { + } else { + EXPECT_TRUE(1) << "Testing clause " << clause; + } randomString(&r); c = r; EXPECT_EQ(c, r); @@ -1020,7 +1045,9 @@ TEST(FBString, testAllClauses) { auto mbv = std::vector(wret + 1); auto mb = mbv.data(); int ret = wcstombs(mb, wc.c_str(), wret + 1); - if (ret == wret) mb[wret] = '\0'; + if (ret == wret) { + mb[wret] = '\0'; + } const char *mc = c.c_str(); std::string one(mb); std::string two(mc); @@ -1209,7 +1236,7 @@ TEST(FBString, testMoveOperatorPlusRhs) { // 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) { - EXPECT_THROW(fbstring s(0), std::logic_error); + EXPECT_THROW(fbstring s(nullptr), std::logic_error); } TEST(FBString, testFixedBugs) { @@ -1419,7 +1446,7 @@ struct TestStructStringAllocator : std::allocator { } }; -} // anon namespace +} // namespace TEST(FBStringCtorTest, DefaultInitStructDefaultAlloc) { TestStructDefaultAllocator t1 { };