diff options
| author | Leitwolf11 | 2026-11-16 12:42:14 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-16 12:42:14 +0300 |
| commit | 5a63d9c746daa1748db7622a5e3effb9ca5c4b40 (patch) | |
| tree | f04d44d03b84c93b0383dfbce492b32b1c23dc76 /tests/Progmasoft/BazelModule/WithMain.tests.cpp | |
| parent | c7c952b01ef0895f82d381e7ad23172a0edaaab1 (diff) | |
| download | catch3-build/bcr.tar.gz | |
Test behavior in the test module, not constantsbuild/bcr
Codacy (cppcheck) found both conditions always true. The module now
checks a generated repetition count with catch3_main, and sections that
each start from the same fixture with its own main.
Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'tests/Progmasoft/BazelModule/WithMain.tests.cpp')
| -rw-r--r-- | tests/Progmasoft/BazelModule/WithMain.tests.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/Progmasoft/BazelModule/WithMain.tests.cpp b/tests/Progmasoft/BazelModule/WithMain.tests.cpp index b3843f9f..60f67ed1 100644 --- a/tests/Progmasoft/BazelModule/WithMain.tests.cpp +++ b/tests/Progmasoft/BazelModule/WithMain.tests.cpp @@ -2,12 +2,28 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Tests linked with @progmasoft_catch3//:catch3_main, which brings main. +#include <Progmasoft/Catch3/Generators/Generators.hpp> #include <Progmasoft/Catch3/TestMacros.hpp> #include <string> -TEST_CASE("A test runs from the published module", "[module]") +namespace { - const std::string name = "progmasoft_catch3"; - REQUIRE(name.size() == 17); - CHECK(name.rfind("progmasoft_", 0) == 0); + std::string + Repeat(const std::string &text, int count) + { + std::string result; + for (int i = 0; i < count; ++i) + { + result += text; + } + return result; + } +} // namespace + +TEST_CASE("Generated values reach the test", "[module]") +{ + const int count = GENERATE(0, 1, 3); + const std::string repeated = Repeat("ab", count); + REQUIRE(repeated.size() == static_cast<std::size_t>(2 * count)); + CHECK(repeated.find("ba") == (count > 1 ? 1U : std::string::npos)); } |