| Name: Test | |||||
| Version: 0.0.0 | |||||
| Test-Driver: Catch |
| #pragma once | |||||
| namespace stuff { | |||||
| int calculate(int a, int b) { | |||||
| int result = a + b; | |||||
| if (result == 42) { | |||||
| return result; | |||||
| } else { | |||||
| return 42; | |||||
| } | |||||
| } | |||||
| } // namespace stuff |
| #define CATCH_CONFIG_RUNNER | |||||
| #include <catch2/catch.hpp> | |||||
| #include <testlib/calc.hpp> | |||||
| TEST_CASE("A simple test case") { | |||||
| CHECK_FALSE(false); | |||||
| CHECK(2 == 2); | |||||
| CHECK(1 != 4); | |||||
| CHECK(stuff::calculate(3, 11) == 42); | |||||
| } | |||||
| int main(int argc, char** argv) { | |||||
| // We provide our own runner | |||||
| return Catch::Session().run(argc, argv); | |||||
| } |
| Name: Test | |||||
| Version: 0.0.0 | |||||
| Test-Driver: Catch-Main |
| #pragma once | |||||
| namespace stuff { | |||||
| int calculate(int a, int b) { | |||||
| int result = a + b; | |||||
| if (result == 42) { | |||||
| return result; | |||||
| } else { | |||||
| return 42; | |||||
| } | |||||
| } | |||||
| } // namespace stuff |
| #include <catch2/catch.hpp> | |||||
| #include <testlib/calc.hpp> | |||||
| TEST_CASE("A simple test case") { | |||||
| CHECK_FALSE(false); | |||||
| CHECK(2 == 2); | |||||
| CHECK(1 != 4); | |||||
| CHECK(stuff::calculate(3, 11) == 42); | |||||
| } |
| from tests import DDS, dds_fixture_conf, DDSFixtureParams | |||||
| from dds_ci import proc | |||||
| @dds_fixture_conf( | |||||
| DDSFixtureParams('main', 'main'), | |||||
| DDSFixtureParams('custom-runner', 'custom-runner'), | |||||
| ) | |||||
| def test_catch_testdriver(dds: DDS): | |||||
| dds.build(tests=True) | |||||
| test_exe = dds.build_dir / f'test/calc{dds.exe_suffix}' | |||||
| assert test_exe.exists() | |||||
| assert proc.run([test_exe]).returncode == 0 |