diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel index 78a09fdf37..f87088da7d 100644 --- a/cscore/BUILD.bazel +++ b/cscore/BUILD.bazel @@ -223,10 +223,10 @@ wpilib_jni_java_library( cc_test( name = "cscore-cpp-test", size = "small", - srcs = glob(["src/test/native/**"]), + srcs = glob(["src/test/native/**/*.cpp"]), deps = [ ":cscore", - "//thirdparty/googletest", + "//thirdparty/catch2", ], ) diff --git a/cscore/CMakeLists.txt b/cscore/CMakeLists.txt index 68cc694743..ac902ba5f4 100644 --- a/cscore/CMakeLists.txt +++ b/cscore/CMakeLists.txt @@ -76,6 +76,6 @@ foreach(example ${cscore_examples}) endforeach() if(WITH_TESTS) - wpilib_add_test(cscore src/test/native/cpp) - target_link_libraries(cscore_test cscore googletest) + wpilib_add_test_catch2(cscore src/test/native/cpp) + target_link_libraries(cscore_test cscore) endif() diff --git a/cscore/build.gradle b/cscore/build.gradle index 558c7ab302..3fe57ffe80 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -3,6 +3,7 @@ import org.gradle.internal.os.OperatingSystem ext { nativeName = 'cscore' devMain = 'org.wpilib.cscore.DevMain' + nativeTestSuiteName = "${nativeName}Catch2Test" } // Removed because having the objective-cpp plugin added breaks @@ -70,7 +71,7 @@ ext { sharedCvConfigs = [cscore : [], cscoreBase: [], cscoreDev : [], - cscoreTest: [], + (nativeTestSuiteName): [], cscoreJNIShared: []] staticCvConfigs = [cscoreJNI: [], cscoreJNICvStatic: []] diff --git a/cscore/src/test/native/cpp/CameraSourceTest.cpp b/cscore/src/test/native/cpp/CameraSourceTest.cpp index 913396dde5..7c5309ffc1 100644 --- a/cscore/src/test/native/cpp/CameraSourceTest.cpp +++ b/cscore/src/test/native/cpp/CameraSourceTest.cpp @@ -2,19 +2,14 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include +#include #include "wpi/cs/HttpCamera.hpp" #include "wpi/cs/cscore_cpp.hpp" namespace wpi::cs { -class CameraSourceTest : public ::testing::Test { - protected: - CameraSourceTest() = default; -}; - -TEST_F(CameraSourceTest, HTTPCamera) { +TEST_CASE("CameraSourceTest HTTPCamera", "[cscore][camera-source]") { auto source = HttpCamera("camera", "http://localhost:8000"); wpi::cs::Shutdown(); } diff --git a/cscore/src/test/native/cpp/RawSourceTest.cpp b/cscore/src/test/native/cpp/RawSourceTest.cpp index 82854ba04a..287b1afc3e 100644 --- a/cscore/src/test/native/cpp/RawSourceTest.cpp +++ b/cscore/src/test/native/cpp/RawSourceTest.cpp @@ -4,15 +4,15 @@ #include "wpi/cs/RawSource.hpp" -#include +#include namespace wpi::cs { -TEST(RawSourceTest, CreateEmpty) { +TEST_CASE("RawSourceTest CreateEmpty", "[cscore][raw-source]") { RawSource source; } -TEST(RawSourceTest, Create) { +TEST_CASE("RawSourceTest Create", "[cscore][raw-source]") { RawSource source("test", wpi::util::PixelFormat::BGR, 640, 480, 30); } diff --git a/cscore/src/test/native/cpp/main.cpp b/cscore/src/test/native/cpp/main.cpp index e993c1f14e..a2c05f2d23 100644 --- a/cscore/src/test/native/cpp/main.cpp +++ b/cscore/src/test/native/cpp/main.cpp @@ -2,10 +2,8 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include +#include int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; + return Catch::Session().run(argc, argv); }