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

Add missing tests for Array and Table

parent e59df8f8
Branches
No related tags found
1 merge request!199Integrate checkpointing
...@@ -448,6 +448,10 @@ TEST_CASE("Array", "[utils]") ...@@ -448,6 +448,10 @@ TEST_CASE("Array", "[utils]")
REQUIRE(sum_before_shuffle == sum_after_shuffle); REQUIRE(sum_before_shuffle == sum_after_shuffle);
REQUIRE(sum_before_shuffle == Catch::Approx(direct_sum(array))); REQUIRE(sum_before_shuffle == Catch::Approx(direct_sum(array)));
ReproducibleSumManager::setReproducibleSums(false);
REQUIRE(sum(array) == Catch::Approx(direct_sum(array)));
ReproducibleSumManager::setReproducibleSums(true);
} }
SECTION("reproducible float sum") SECTION("reproducible float sum")
...@@ -1250,6 +1254,19 @@ TEST_CASE("Array", "[utils]") ...@@ -1250,6 +1254,19 @@ TEST_CASE("Array", "[utils]")
} }
} }
} }
SECTION("non reproducible double sum")
{
Array<double> array(10'000);
for (size_t i = 0; i < array.size(); ++i) {
array[i] = ((i < (array.size() / 10)) * 1E25 + 1E10) * ((i + 1) % 1'000) * std::sin(3 * i + 1);
}
ReproducibleSumManager::setReproducibleSums(false);
REQUIRE(sum(array) == Catch::Approx(direct_sum(array)));
ReproducibleSumManager::setReproducibleSums(true);
}
} }
SECTION("checking for subArrayView") SECTION("checking for subArrayView")
...@@ -1295,6 +1312,10 @@ TEST_CASE("Array", "[utils]") ...@@ -1295,6 +1312,10 @@ TEST_CASE("Array", "[utils]")
REQUIRE(array[i] == 2 * int_i + 1); REQUIRE(array[i] == 2 * int_i + 1);
} }
} }
std::ostringstream os;
os << view;
REQUIRE(os.str() == "0:3 1:1 2:-1 3:-3 4:-5 5:-7");
} }
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -310,6 +310,12 @@ TEST_CASE("Table", "[utils]") ...@@ -310,6 +310,12 @@ TEST_CASE("Table", "[utils]")
} }
} }
} }
std::ostringstream os;
os << sub_table_view;
REQUIRE(os.str() == R"(0| 0:5 1:8 2:11
1| 0:2 1:-1 2:-4
)");
} }
SECTION("UnsafeRowView") SECTION("UnsafeRowView")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment