Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix narrowing conversions in Result Test #282

Merged
merged 3 commits into from
Jun 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Tests/UnitTests/Core/Utilities/ResultTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {
{
using Result = Result<double, MyError>;

Result res(42);
Result res(42.);
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 42.);

Expand All @@ -102,11 +102,11 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {
{
using Result = Result<double, std::error_code>;

Result res(42);
Result res(42.);
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 42.);
BOOST_CHECK_EQUAL(res.value(), 42u);
res = 46;
res = 46.;
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 46.);
BOOST_CHECK_EQUAL(res.value(), 46u);
Expand All @@ -124,11 +124,11 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {

{
using Result = Result<double, const char*>;
Result res{0};
Result res{0.};
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 0.0);

res = 1;
res = 1.;
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 1.0);

Expand All @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {

{
using Result = Result<const char*, double>;
Result res{0};
Result res{0.};
BOOST_CHECK(!res.ok());
BOOST_CHECK_EQUAL(res.error(), 0.0);

Expand All @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {
BOOST_CHECK(res2.ok());
BOOST_CHECK_EQUAL(res2.value(), "blibb");

res2 = 0;
res2 = 0.;
BOOST_CHECK(!res2.ok());
BOOST_CHECK_EQUAL(res2.error(), 0.0);
}
Expand All @@ -181,15 +181,16 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) {
{
using Result = Result<double>;

Result res(42);
Result res(42.);
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 42.);
BOOST_CHECK_EQUAL(res.value(), 42u);
res = 46;
res = 46.;
BOOST_CHECK(res.ok());
BOOST_CHECK_EQUAL(*res, 46.);
BOOST_CHECK_EQUAL(res.value(), 46u);


Result res2(ec);
BOOST_CHECK(!res2.ok());
BOOST_CHECK_EQUAL(res2.error(), ec);
Expand Down