| @@ -0,0 +1,4 @@ | |||
| Name: Test | |||
| Version: 0.0.0 | |||
| Test-Driver: Catch | |||
| @@ -0,0 +1,14 @@ | |||
| #pragma once | |||
| namespace stuff { | |||
| int calculate(int a, int b) { | |||
| int result = a + b; | |||
| if (result == 42) { | |||
| return result; | |||
| } else { | |||
| return 42; | |||
| } | |||
| } | |||
| } // namespace stuff | |||
| @@ -0,0 +1,16 @@ | |||
| #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); | |||
| } | |||
| @@ -0,0 +1,4 @@ | |||
| Name: Test | |||
| Version: 0.0.0 | |||
| Test-Driver: Catch-Main | |||
| @@ -0,0 +1,14 @@ | |||
| #pragma once | |||
| namespace stuff { | |||
| int calculate(int a, int b) { | |||
| int result = a + b; | |||
| if (result == 42) { | |||
| return result; | |||
| } else { | |||
| return 42; | |||
| } | |||
| } | |||
| } // namespace stuff | |||
| @@ -0,0 +1,10 @@ | |||
| #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); | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| 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 | |||