diff options
Diffstat (limited to 'test/buildtool/multithreading')
5 files changed, 51 insertions, 15 deletions
diff --git a/test/buildtool/multithreading/async_map.test.cpp b/test/buildtool/multithreading/async_map.test.cpp index 589b799a..30a6322a 100644 --- a/test/buildtool/multithreading/async_map.test.cpp +++ b/test/buildtool/multithreading/async_map.test.cpp @@ -14,7 +14,7 @@ #include <string> -#include "catch2/catch.hpp" +#include "catch2/catch_test_macros.hpp" #include "src/buildtool/multithreading/async_map.hpp" #include "src/buildtool/multithreading/async_map_node.hpp" #include "src/buildtool/multithreading/task_system.hpp" diff --git a/test/buildtool/multithreading/async_map_consumer.test.cpp b/test/buildtool/multithreading/async_map_consumer.test.cpp index f9cbc36b..4e8df652 100644 --- a/test/buildtool/multithreading/async_map_consumer.test.cpp +++ b/test/buildtool/multithreading/async_map_consumer.test.cpp @@ -16,7 +16,8 @@ #include <numeric> #include <string> -#include "catch2/catch.hpp" +#include "catch2/catch_test_macros.hpp" +#include "catch2/matchers/catch_matchers_all.hpp" #include "src/buildtool/multithreading/async_map.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/multithreading/task_system.hpp" diff --git a/test/buildtool/multithreading/async_map_node.test.cpp b/test/buildtool/multithreading/async_map_node.test.cpp index 8aa8f598..8dd9bf89 100644 --- a/test/buildtool/multithreading/async_map_node.test.cpp +++ b/test/buildtool/multithreading/async_map_node.test.cpp @@ -16,7 +16,8 @@ #include <string> #include <thread> -#include "catch2/catch.hpp" +#include "catch2/catch_test_macros.hpp" +#include "catch2/matchers/catch_matchers_all.hpp" #include "src/buildtool/multithreading/async_map_node.hpp" #include "src/buildtool/multithreading/task_system.hpp" diff --git a/test/buildtool/multithreading/task.test.cpp b/test/buildtool/multithreading/task.test.cpp index c39067ed..cb540def 100644 --- a/test/buildtool/multithreading/task.test.cpp +++ b/test/buildtool/multithreading/task.test.cpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "catch2/catch.hpp" +#include "catch2/catch_test_macros.hpp" #include "src/buildtool/multithreading/task.hpp" namespace { - +constexpr int kDummyValue{5}; struct StatelessCallable { void operator()() noexcept {} }; @@ -25,7 +25,7 @@ struct ValueCaptureCallable { explicit ValueCaptureCallable(int i) noexcept : number{i} {} // NOLINTNEXTLINE - void operator()() noexcept { number += 5; } + void operator()() noexcept { number += kDummyValue; } int number; }; @@ -125,12 +125,24 @@ TEST_CASE("Task constructed from lambda is not empty", "[task]") { SECTION("Value capture") { int a = 1; // NOLINTNEXTLINE - Task t_value{[num = a]() mutable { num += 5; }}; + Task t_value{[num = a]() mutable { + num += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(num); + }}; // NOLINTNEXTLINE - auto lambda = [num = a]() mutable { num += 5; }; + auto lambda = [num = a]() mutable { + num += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(num); + }; Task t_from_named_lambda_value_capture{lambda}; - CHECK(Task{[num = a]() mutable { num += 5; }}); + CHECK(Task{[num = a]() mutable { + num += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(num); + }}); CHECK(Task{lambda}); CHECK(t_value); CHECK(t_from_named_lambda_value_capture); @@ -174,7 +186,11 @@ TEST_CASE("Task can be executed and doesn't steal contents", "[task]") { int const initial_value = 2; int num = initial_value; // NOLINTNEXTLINE - Task t_add_five{[a = num]() mutable { a += 5; }}; + Task t_add_five{[a = num]() mutable { + a += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(a); + }}; t_add_five(); // Internal data can not be observed, external data does not change @@ -197,7 +213,11 @@ TEST_CASE("Task can be executed and doesn't steal contents", "[task]") { int const initial_value = 2; int num = initial_value; // NOLINTNEXTLINE - auto add_five = [a = num]() mutable { a += 5; }; + auto add_five = [a = num]() mutable { + a += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(a); + }; Task t_add_five{add_five}; t_add_five(); @@ -227,7 +247,11 @@ TEST_CASE("Task can be executed and doesn't steal contents", "[task]") { int const initial_value = 2; int num = initial_value; // NOLINTNEXTLINE - std::function<void()> add_five{[a = num]() mutable { a += 5; }}; + std::function<void()> add_five{[a = num]() mutable { + a += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(a); + }}; Task t_add_five{add_five}; t_add_five(); @@ -295,7 +319,11 @@ TEST_CASE("Task moving from named object can be executed", "[task]") { int const initial_value = 2; int num = initial_value; // NOLINTNEXTLINE - auto add_five = [a = num]() mutable { a += 5; }; + auto add_five = [a = num]() mutable { + a += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(a); + }; Task t_add_five{std::move(add_five)}; t_add_five(); @@ -320,7 +348,11 @@ TEST_CASE("Task moving from named object can be executed", "[task]") { int const initial_value = 2; int num = initial_value; // NOLINTNEXTLINE - std::function<void()> add_five{[a = num]() mutable { a += 5; }}; + std::function<void()> add_five{[a = num]() mutable { + a += kDummyValue; + // get rid of "set but unused var" + static_cast<void>(a); + }}; Task t_add_five{std::move(add_five)}; t_add_five(); diff --git a/test/buildtool/multithreading/task_system.test.cpp b/test/buildtool/multithreading/task_system.test.cpp index 82b2e2a0..694158ba 100644 --- a/test/buildtool/multithreading/task_system.test.cpp +++ b/test/buildtool/multithreading/task_system.test.cpp @@ -19,7 +19,9 @@ #include <thread> #include <unordered_set> -#include "catch2/catch.hpp" +#include "catch2/catch_test_macros.hpp" +#include "catch2/generators/catch_generators_all.hpp" +#include "catch2/matchers/catch_matchers_all.hpp" #include "src/buildtool/multithreading/task_system.hpp" #include "test/utils/container_matchers.hpp" |