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

Fixes #755 Log compatibility with std::fixed and std::setprecision #832

Merged
merged 4 commits into from
Dec 16, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/mlpack/tests/cli_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ BOOST_AUTO_TEST_CASE(TestPrefixedOutStreamModifiers)
"I have a precise number which is 000156");
}

/**
* Test formatted output.
*/
BOOST_AUTO_TEST_CASE(TestFormattedOutput)
{
std::stringstream ss;
PrefixedOutStream pss(ss, BASH_GREEN "[INFO ]" BASH_CLEAR);

const double pi = std::acos(-1.0);
pss << std::setprecision(10) << pi;

BOOST_REQUIRE_EQUAL(ss.str(),
BASH_GREEN "[INFO ]" BASH_CLEAR "3.141592654");
}
/**
* We should be able to start and then stop a timer multiple times and it should
* save the value.
Expand Down Expand Up @@ -749,18 +763,5 @@ BOOST_AUTO_TEST_CASE(UnmappedParamTest)

BOOST_REQUIRE_EQUAL(CLI::GetUnmappedParam<arma::mat>("matrix2"), "file1.csv");
}
/**
* Test formatted output.
*/
BOOST_AUTO_TEST_CASE(TestFormattedOutput)
{
std::stringstream ss;
PrefixedOutStream pss(ss, BASH_GREEN "[INFO ]" BASH_CLEAR);

const double pi = std::acos(-1.0);
pss << std::setprecision(10) << pi;

BOOST_REQUIRE_EQUAL(ss.str(),
BASH_GREEN "[INFO ]" BASH_CLEAR "3.141592654");
}
BOOST_AUTO_TEST_SUITE_END();