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

summaryrefslogtreecommitdiffhomepage
path: root/tests/Progmasoft
diff options
context:
space:
mode:
authorLeitwolf2026-11-16 14:48:52 +0300
committerGitHub2026-11-16 14:48:52 +0300
commit57dc4f2fee6881884b10085e85927a0c1710ea61 (patch)
treef04d44d03b84c93b0383dfbce492b32b1c23dc76 /tests/Progmasoft
parent48a52e544ae90d6767240a8b5f030350795fbd7b (diff)
parent5a63d9c746daa1748db7622a5e3effb9ca5c4b40 (diff)
downloadcatch3-devel.tar.gz
Merge pull request #48 from Progmasoft/build/bcrHEADdevel
Prepare the Bazel Central Registry entry as progmasoft_catch3
Diffstat (limited to 'tests/Progmasoft')
-rw-r--r--tests/Progmasoft/BazelModule/.bazelrc12
-rw-r--r--tests/Progmasoft/BazelModule/BUILD.bazel16
-rw-r--r--tests/Progmasoft/BazelModule/MODULE.bazel14
-rw-r--r--tests/Progmasoft/BazelModule/OwnMain.tests.cpp31
-rw-r--r--tests/Progmasoft/BazelModule/WithMain.tests.cpp29
5 files changed, 102 insertions, 0 deletions
diff --git a/tests/Progmasoft/BazelModule/.bazelrc b/tests/Progmasoft/BazelModule/.bazelrc
new file mode 100644
index 00000000..b99caaba
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/.bazelrc
@@ -0,0 +1,12 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# Code that includes the headers of Catch3 is C++17 or later, as it must be in
+# a user's module; MSVC defaults to C++14.
+common --enable_platform_specific_config
+build:linux --cxxopt=-std=c++17
+build:macos --cxxopt=-std=c++17
+build:windows --cxxopt=/std:c++17
+
+# The lockfile is the user's; this module keeps none.
+common --lockfile_mode=off
diff --git a/tests/Progmasoft/BazelModule/BUILD.bazel b/tests/Progmasoft/BazelModule/BUILD.bazel
new file mode 100644
index 00000000..c95b5ddf
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/BUILD.bazel
@@ -0,0 +1,16 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+load("@rules_cc//cc:defs.bzl", "cc_test")
+
+# Each public name of the module, as a user links it.
+cc_test(
+ name = "with_main",
+ srcs = ["WithMain.tests.cpp"],
+ deps = ["@progmasoft_catch3//:catch3_main"],
+)
+
+cc_test(
+ name = "own_main",
+ srcs = ["OwnMain.tests.cpp"],
+ deps = ["@progmasoft_catch3//:catch3"],
+)
diff --git a/tests/Progmasoft/BazelModule/MODULE.bazel b/tests/Progmasoft/BazelModule/MODULE.bazel
new file mode 100644
index 00000000..fa0d4bdb
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/MODULE.bazel
@@ -0,0 +1,14 @@
+# Copyright (c) 2026 Progmasoft.
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+# A module that uses progmasoft_catch3 as a user's does. CI builds it from this
+# checkout; the Bazel Central Registry builds it from the published version.
+module(name = "progmasoft_catch3_test_module")
+
+bazel_dep(name = "progmasoft_catch3")
+local_path_override(
+ module_name = "progmasoft_catch3",
+ path = "../../..",
+)
+
+bazel_dep(name = "rules_cc", version = "0.2.17")
diff --git a/tests/Progmasoft/BazelModule/OwnMain.tests.cpp b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
new file mode 100644
index 00000000..92c4d711
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp
@@ -0,0 +1,31 @@
+// Copyright (c) 2026 Progmasoft.
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+// 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("Sections run against a fresh fixture", "[module]")
+{
+ 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
+main(int argc, char **argv)
+{
+ Catch::Session session;
+ return session.run(argc, argv);
+}
diff --git a/tests/Progmasoft/BazelModule/WithMain.tests.cpp b/tests/Progmasoft/BazelModule/WithMain.tests.cpp
new file mode 100644
index 00000000..60f67ed1
--- /dev/null
+++ b/tests/Progmasoft/BazelModule/WithMain.tests.cpp
@@ -0,0 +1,29 @@
+// Copyright (c) 2026 Progmasoft.
+// 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>
+
+namespace
+{
+ 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));
+}