Skip to content
Snippets Groups Projects
Commit ef9a9edc authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Make Vector output more readable and use NaNHelper

parent 75e9b183
No related branches found
No related tags found
1 merge request!105Add NaNHelper utility
This commit is part of merge request !105. Comments created here will be created in the context of that merge request.
......@@ -2,6 +2,7 @@
#define VECTOR_HPP
#include <utils/Array.hpp>
#include <utils/NaNHelper.hpp>
#include <utils/PugsAssert.hpp>
#include <utils/PugsMacros.hpp>
#include <utils/PugsUtils.hpp>
......@@ -28,8 +29,11 @@ class Vector // LCOV_EXCL_LINE
friend std::ostream&
operator<<(std::ostream& os, const Vector& x)
{
for (size_t i = 0; i < x.size(); ++i) {
os << ' ' << x[i];
if (x.size() > 0) {
os << 0 << ':' << NaNHelper(x[0]);
}
for (size_t i = 1; i < x.size(); ++i) {
os << ' ' << i << ':' << NaNHelper(x[i]);
}
return os;
}
......
......@@ -371,8 +371,9 @@ TEST_CASE("Vector", "[algebra]")
std::ostringstream vector_ost;
vector_ost << x;
std::ostringstream ref_ost;
for (size_t i = 0; i < x.size(); ++i) {
ref_ost << ' ' << x[i];
ref_ost << 0 << ':' << x[0];
for (size_t i = 1; i < x.size(); ++i) {
ref_ost << ' ' << i << ':' << x[i];
}
REQUIRE(vector_ost.str() == ref_ost.str());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment