EXPECT_TRUE(shouldWork == std::numeric_limits<float>::min() ||
shouldWork == 0.f);
} catch (...) {
- EXPECT_TRUE(false);
+ ADD_FAILURE();
}
}
// Test NaN conversion
try {
to<double>("not a number");
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (const std::range_error &) {
}
try {
to<int>(pc);
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (const std::range_error &) {
}
}
try {
to<int64_t>(&pc);
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (const std::range_error &) {
}
}
try {
to<double>(pc);
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (const std::range_error &) {
}
}
/* This seems not work in ubuntu11.10, gcc 4.6.1
try {
auto f = to<float>(957837589847);
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (std::range_error& e) {
//LOG(INFO) << e.what();
}
try {
auto i2 = to<int>(42.1);
LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing";
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (std::range_error&) {
//LOG(INFO) << e.what();
}
LOG(ERROR) << "to<char> returned "
<< static_cast<unsigned int>(i2)
<< " instead of throwing";
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (std::range_error&) {
//LOG(INFO) << e.what();
}
LOG(ERROR) << "to<A> returned "
<< static_cast<unsigned int>(i2)
<< " instead of throwing";
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (std::range_error&) {
//LOG(INFO) << e.what();
}
try {
auto i = to<int32_t>(x);
LOG(ERROR) << "to<int32_t> returned " << i << " instead of throwing";
- EXPECT_TRUE(false);
+ ADD_FAILURE();
} catch (std::range_error&) {
}
}
std::string where = to<std::string>(__FILE__, "(", line, "): ");
try {
auto res = expr();
- EXPECT_TRUE(false) << where << exprStr << " -> " << res;
+ ADD_FAILURE() << where << exprStr << " -> " << res;
} catch (const ConversionError& e) {
EXPECT_EQ(code, e.errorCode()) << where << exprStr;
std::string str(e.what());
bool handled = false;
auto expect_runtime_error_yes_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::logic_error&) { EXPECT_TRUE(false); },
+ [](const std::logic_error&) { ADD_FAILURE(); },
[&](const std::runtime_error&) { handled = true; },
- [](const std::exception&) { EXPECT_TRUE(false); },
- [](...) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); },
+ [](...) { ADD_FAILURE(); });
};
expect_runtime_error_yes_catch_all(ew_eptr);
auto expect_runtime_error_no_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::logic_error&) { EXPECT_TRUE(false); },
+ [](const std::logic_error&) { ADD_FAILURE(); },
[&](const std::runtime_error&) { handled = true; },
- [](const std::exception&) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); });
};
expect_runtime_error_no_catch_all(ew_eptr);
auto expect_runtime_error_catch_non_std = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::logic_error&) { EXPECT_TRUE(false); },
+ [](const std::logic_error&) { ADD_FAILURE(); },
[&](const std::runtime_error&) { handled = true; },
- [](const std::exception&) { EXPECT_TRUE(false); },
- [](const int&) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); },
+ [](const int&) { ADD_FAILURE(); });
};
expect_runtime_error_catch_non_std(ew_eptr);
// outer handler:
auto expect_runtime_error_rethrow = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::logic_error&) { EXPECT_TRUE(false); },
+ [](const std::logic_error&) { ADD_FAILURE(); },
[&](const std::runtime_error& e) {
handled = true;
throw e;
},
- [](const std::exception&) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); });
};
EXPECT_THROW(expect_runtime_error_rethrow(ew_eptr), std::runtime_error);
bool handled = false;
auto expect_runtime_error_yes_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::logic_error&) { EXPECT_TRUE(false); },
- [](const std::runtime_error&) { EXPECT_TRUE(false); },
+ [](const std::logic_error&) { ADD_FAILURE(); },
+ [](const std::runtime_error&) { ADD_FAILURE(); },
[&](...) { handled = true; });
};
auto expect_int_yes_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::exception&) { EXPECT_TRUE(false); },
+ [](const std::exception&) { ADD_FAILURE(); },
[&](...) { handled = true; });
};
auto expect_int_no_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::exception&) { EXPECT_TRUE(false); },
+ [](const std::exception&) { ADD_FAILURE(); },
[&](const int&) { handled = true; });
};
auto expect_int_no_catch_all_2 = [&](const exception_wrapper& ew) {
ew.handle(
[&](const int&) { handled = true; },
- [](const std::exception&) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); });
};
expect_int_no_catch_all_2(ew_eptr1);
auto expect_int_yes_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::exception&) { EXPECT_TRUE(false); },
+ [](const std::exception&) { ADD_FAILURE(); },
[&](...) { handled = true; });
};
auto expect_int_no_catch_all = [&](const exception_wrapper& ew) {
ew.handle(
- [](const std::exception&) { EXPECT_TRUE(false); },
+ [](const std::exception&) { ADD_FAILURE(); },
[&](const BigNonStdError&) { handled = true; });
};
auto expect_int_no_catch_all_2 = [&](const exception_wrapper& ew) {
ew.handle(
[&](const BigNonStdError&) { handled = true; },
- [](const std::exception&) { EXPECT_TRUE(false); });
+ [](const std::exception&) { ADD_FAILURE(); });
};
expect_int_no_catch_all_2(ew_eptr1);
handled = true;
throw e;
},
- [](const BaseException&) { EXPECT_TRUE(false); }),
+ [](const BaseException&) { ADD_FAILURE(); }),
DerivedException);
EXPECT_TRUE(handled);
handled = false;
handled = true;
throw e;
},
- [](...) { EXPECT_TRUE(false); }),
+ [](...) { ADD_FAILURE(); }),
DerivedException);
EXPECT_TRUE(handled);
}