* 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>
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();
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) {
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) {
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);
}