Commit 7cafb313 authored by Michał Karzyński's avatar Michał Karzyński Committed by Scott Cyphers

Test messages improvements (#3018)

* Test messages improvements

* Add comment

* and remove conversion from floating point contexts
parent 530a9e09
......@@ -56,13 +56,14 @@ namespace ngraph
if (count < 5)
{
ar_fail << std::setprecision(std::numeric_limits<long double>::digits10 + 1)
<< a[i] << " is not close to " << b[i] << " at index " << i << "\n";
<< a[i] << " is not close to " << b[i] << " at index " << i
<< std::endl;
}
count++;
rc = false;
}
}
ar_fail << "diff count: " << count << " out of " << a.size() << "\n";
ar_fail << "diff count: " << count << " out of " << a.size() << std::endl;
return rc ? ::testing::AssertionSuccess() : ar_fail;
}
......@@ -90,7 +91,9 @@ namespace ngraph
T abs_diff = (a[i] > b[i]) ? (a[i] - b[i]) : (b[i] - a[i]);
if (abs_diff > atol + rtol * b[i])
{
ar_fail << a[i] << " is not close to " << b[i] << " at index " << i;
// use unary + operator to force integral values to be displayed as numbers
ar_fail << +a[i] << " is not close to " << +b[i] << " at index " << i
<< std::endl;
rc = false;
}
}
......
......@@ -375,7 +375,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
if (diff_count < 5)
{
msg << std::setprecision(std::numeric_limits<long double>::digits10 + 1) << a[i]
<< " is not close to " << b[i] << " at index " << i << "\n";
<< " is not close to " << b[i] << " at index " << i << std::endl;
}
rc = false;
......@@ -384,7 +384,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
}
if (!rc)
{
msg << "diff count: " << diff_count << " out of " << a.size() << "\n";
msg << "diff count: " << diff_count << " out of " << a.size() << std::endl;
}
// Find median value via partial sorting
size_t middle = distances.size() / 2;
......@@ -407,7 +407,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
<< tolerance_bits << " tolerance). ";
if (all_below_min_signal)
{
std::cout << "All values below min_signal: " << min_signal << "\n";
std::cout << "All values below min_signal: " << min_signal << std::endl;
}
else
{
......@@ -422,11 +422,11 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
<< " tolerance bits)\n";
if (all_below_min_signal)
{
msg << "All values below min_signal: " << min_signal << "\n";
msg << "All values below min_signal: " << min_signal << std::endl;
}
else
{
msg << below_min_count << " value(s) below min_signal: " << min_signal << "\n";
msg << below_min_count << " value(s) below min_signal: " << min_signal << std::endl;
msg << std::setprecision(std::numeric_limits<long double>::digits10 + 1)
<< "tightest match - mismatch occurred @ mantissa bit: "
<< matching_mantissa_bits(min_distance) << " or next bit (" << a[min_distance_index]
......@@ -506,7 +506,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
{
if (diff_count < 5)
{
msg << a[i] << " is not close to " << b[i] << " at index " << i << "\n";
msg << a[i] << " is not close to " << b[i] << " at index " << i << std::endl;
}
rc = false;
......@@ -515,7 +515,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
}
if (!rc)
{
msg << "diff count: " << diff_count << " out of " << a.size() << "\n";
msg << "diff count: " << diff_count << " out of " << a.size() << std::endl;
}
// Find median value via partial sorting
size_t middle = distances.size() / 2;
......@@ -540,7 +540,7 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
<< " tolerance). ";
if (all_below_min_signal)
{
std::cout << "All values below min_signal: " << min_signal << "\n";
std::cout << "All values below min_signal: " << min_signal << std::endl;
}
else
{
......@@ -555,11 +555,11 @@ uint32_t test::matching_mantissa_bits(uint64_t distance)
<< " tolerance bits)\n";
if (all_below_min_signal)
{
msg << "All values below min_signal: " << min_signal << "\n";
msg << "All values below min_signal: " << min_signal << std::endl;
}
else
{
msg << below_min_count << " value(s) below min_signal: " << min_signal << "\n";
msg << below_min_count << " value(s) below min_signal: " << min_signal << std::endl;
msg << std::setprecision(std::numeric_limits<long double>::digits10 + 1)
<< "tightest match - mismatch occurred @ mantissa bit: "
<< matching_mantissa_bits(min_distance) << " or next bit (" << a[min_distance_index]
......
......@@ -293,12 +293,12 @@ string get_results_str(const std::vector<char>& ref_data,
ss << "First " << num_results << " results";
for (size_t i = 0; i < num_results; ++i)
{
ss << "\n"
ss << std::endl
<< std::setw(4) << i << " ref: " << std::setw(16) << std::left
<< static_cast<int>(ref_data[i]) << " actual: " << std::setw(16) << std::left
<< static_cast<int>(actual_data[i]);
}
ss << "\n";
ss << std::endl;
return ss.str();
}
......
......@@ -231,11 +231,12 @@ std::string get_results_str(const std::vector<T>& ref_data,
ss << "First " << num_results << " results";
for (size_t i = 0; i < num_results; ++i)
{
ss << "\n"
<< std::setw(4) << i << " ref: " << std::setw(16) << std::left << ref_data[i]
<< " actual: " << std::setw(16) << std::left << actual_data[i];
ss << std::endl
// use unary + operator to force integral values to be displayed as numbers
<< std::setw(4) << i << " ref: " << std::setw(16) << std::left << +ref_data[i]
<< " actual: " << std::setw(16) << std::left << +actual_data[i];
}
ss << "\n";
ss << std::endl;
return ss.str();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment