From: Wolfgang Bangerth Date: Tue, 23 Jul 2024 22:23:55 +0000 (-0600) Subject: Adjust tests. X-Git-Tag: v9.6.0-rc1~4^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17373%2Fhead;p=dealii.git Adjust tests. --- diff --git a/tests/base/lazy_01.cc b/tests/base/lazy_01.cc index 8644999974..9dfe429f62 100644 --- a/tests/base/lazy_01.cc +++ b/tests/base/lazy_01.cc @@ -30,6 +30,8 @@ main() initlog(); { + deallog << "Part 1:" << std::endl; + Lazy lazy_integer; deallog << "lazy_integer.has_value() = " << lazy_integer.has_value() << std::endl; @@ -38,7 +40,15 @@ main() deallog << "[initializing object]" << std::endl; return 42; }); - deallog << "lazy_integer.has_value() = " << lazy_integer.has_value() + + // Lazy computes the result on a different task, which may be on a + // different thread. To avoid producing unreliable output, make + // sure we don't say + // deallog << "lazy_integer.has_value() = " << lazy_integer.has_value() + // but the following, where the order of computation and output are + // clear and well defined: + deallog << "lazy_integer.has_value() = " + + std::to_string(lazy_integer.has_value()) << std::endl; deallog << "lazy_integer.value() = " << lazy_integer.value() << std::endl; @@ -47,17 +57,20 @@ main() return -1; }); - deallog << "lazy_integer.value() = " << lazy_integer.value() << std::endl; + deallog << "lazy_integer.value() = " + std::to_string(lazy_integer.value()) + << std::endl; } { + deallog << "Part 2:" << std::endl; + Lazy lazy_integer; - deallog << "lazy_integer.value() = " - << lazy_integer.value_or_initialize([&]() { - deallog << "... [initializing object] ... "; - return 42; - }) + deallog << "lazy_integer.value() = " + + std::to_string(lazy_integer.value_or_initialize([&]() { + deallog << "... [initializing object] ... " << std::endl; + return 42; + })) << std::endl; } diff --git a/tests/base/lazy_01.output b/tests/base/lazy_01.output index 728e7260e7..55b6532134 100644 --- a/tests/base/lazy_01.output +++ b/tests/base/lazy_01.output @@ -1,8 +1,11 @@ +DEAL::Part 1: DEAL::lazy_integer.has_value() = 0 DEAL::[initializing object] DEAL::lazy_integer.has_value() = 1 DEAL::lazy_integer.value() = 42 DEAL::lazy_integer.value() = 42 -DEAL::lazy_integer.value() = ... [initializing object] ... 42 +DEAL::Part 2: +DEAL::... [initializing object] ... +DEAL::lazy_integer.value() = 42 DEAL::OK! diff --git a/tests/base/lazy_02.cc b/tests/base/lazy_02.cc index 4f9aa77a59..b54d119dd7 100644 --- a/tests/base/lazy_02.cc +++ b/tests/base/lazy_02.cc @@ -71,11 +71,11 @@ main() deallog << "... [ reset ] ... " << std::endl; lazy_integer_4.reset(); - deallog << "value_or_initialize: " - << lazy_integer_4.value_or_initialize([&]() { - deallog << "... [ initialized ] ... "; - return 45; - }) + deallog << "value_or_initialize: " + + std::to_string(lazy_integer_4.value_or_initialize([&]() { + deallog << "... [ initialized ] ... " << std::endl; + return 45; + })) << std::endl; deallog << "OK!" << std::endl; diff --git a/tests/base/lazy_02.output b/tests/base/lazy_02.output index 54697dcbb5..a1bba381b2 100644 --- a/tests/base/lazy_02.output +++ b/tests/base/lazy_02.output @@ -11,5 +11,6 @@ DEAL::... [ reset ] ... DEAL::... [ initialized ] ... DEAL::Reset: 43 DEAL::... [ reset ] ... -DEAL::value_or_initialize: ... [ initialized ] ... 45 +DEAL::... [ initialized ] ... +DEAL::value_or_initialize: 45 DEAL::OK!