Don't shadow locals, parameters or fields
[folly.git] / folly / test / ConvTest.cpp
index 2ff1ab08e2e347050d2e67be5a649e1c4cfa0c5a..2109d1a6a2c532308ef26cde3ecb5d934000cece 100644 (file)
  * limitations under the License.
  */
 
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS 1
+#endif
+
 #include <boost/lexical_cast.hpp>
+
 #include <folly/Conv.h>
 #include <folly/Foreach.h>
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
+
 #include <algorithm>
+#include <cinttypes>
 #include <limits>
 #include <sstream>
 #include <stdexcept>
@@ -657,8 +664,8 @@ TEST(Conv, DoubleToInt) {
   auto i = to<int>(42.0);
   EXPECT_EQ(i, 42);
   try {
-    auto i = to<int>(42.1);
-    LOG(ERROR) << "to<int> returned " << i << " instead of throwing";
+    auto i2 = to<int>(42.1);
+    LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing";
     EXPECT_TRUE(false);
   } catch (std::range_error& e) {
     //LOG(INFO) << e.what();
@@ -672,9 +679,9 @@ TEST(Conv, EnumToInt) {
   auto j = to<char>(x);
   EXPECT_EQ(j, 42);
   try {
-    auto i = to<char>(y);
+    auto i2 = to<char>(y);
     LOG(ERROR) << "to<char> returned "
-               << static_cast<unsigned int>(i)
+               << static_cast<unsigned int>(i2)
                << " instead of throwing";
     EXPECT_TRUE(false);
   } catch (std::range_error& e) {
@@ -697,9 +704,9 @@ TEST(Conv, IntToEnum) {
   auto j = to<A>(100);
   EXPECT_EQ(j, 100);
   try {
-    auto i = to<A>(5000000000L);
+    auto i2 = to<A>(5000000000L);
     LOG(ERROR) << "to<A> returned "
-               << static_cast<unsigned int>(i)
+               << static_cast<unsigned int>(i2)
                << " instead of throwing";
     EXPECT_TRUE(false);
   } catch (std::range_error& e) {
@@ -732,7 +739,7 @@ TEST(Conv, UnsignedEnumClass) {
   EXPECT_EQ(E::x, to<E>(3000000000U));
   EXPECT_EQ(E::x, to<E>("3000000000"));
   E e;
-  parseTo("3000000000", e);
+  EXPECT_TRUE(parseTo("3000000000", e).hasValue());
   EXPECT_EQ(E::x, e);
   EXPECT_THROW(to<int32_t>(E::x), std::range_error);
 }