diff --git a/tests/test_Array.cpp b/tests/test_Array.cpp index 28c018cced7ac2c4a2295b1824882a7dc5b492f8..fbac561b8dfd79b15a5cabf4f12f4b9ee2bb1004 100644 --- a/tests/test_Array.cpp +++ b/tests/test_Array.cpp @@ -448,6 +448,10 @@ TEST_CASE("Array", "[utils]") REQUIRE(sum_before_shuffle == sum_after_shuffle); 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") @@ -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") @@ -1295,6 +1312,10 @@ TEST_CASE("Array", "[utils]") 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 diff --git a/tests/test_Table.cpp b/tests/test_Table.cpp index 5ce90fe9ce460041d26ebcfbc88ff891da0ffdde..844c7ab34854de4b890e498226be96ed754b6c8f 100644 --- a/tests/test_Table.cpp +++ b/tests/test_Table.cpp @@ -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")