Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/Progmasoft/BazelModule
diff options
context:
space:
mode:
authorLeitwolf112026-11-16 12:42:14 +0300
committerLeitwolf112026-11-16 12:42:14 +0300
commit5a63d9c746daa1748db7622a5e3effb9ca5c4b40 (patch)
treef04d44d03b84c93b0383dfbce492b32b1c23dc76 /tests/Progmasoft/BazelModule
parentc7c952b01ef0895f82d381e7ad23172a0edaaab1 (diff)
downloadcatch3-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')
-rw-r--r--tests/Progmasoft/BazelModule/OwnMain.tests.cpp17
-rw-r--r--tests/Progmasoft/BazelModule/WithMain.tests.cpp24
2 files changed, 35 insertions, 6 deletions
diff --git a/tests/Progmasoft/BazelModule/OwnMain.tests.cpp b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
index e544bf4d..92c4d711 100644
--- a/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
+++ b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
@@ -4,10 +4,23 @@
// Tests linked with @progmasoft_catch3//:catch3, with a main of their own.
#include <Progmasoft/Catch3/Session.hpp>
#include <Progmasoft/Catch3/TestMacros.hpp>
+#include <algorithm>
+#include <vector>
-TEST_CASE("A test runs under its own main", "[module]")
+TEST_CASE("Sections run against a fresh fixture", "[module]")
{
- REQUIRE(1 + 1 == 2);
+ std::vector<int> values{ 3, 1, 2 };
+
+ SECTION("sorting orders the values")
+ {
+ std::sort(values.begin(), values.end());
+ REQUIRE(std::is_sorted(values.begin(), values.end()));
+ CHECK(values.front() < values.back());
+ }
+ SECTION("each section starts from the same values")
+ {
+ CHECK_FALSE(std::is_sorted(values.begin(), values.end()));
+ }
}
int
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));
}