[sim] Translate unit tests to catch2 (#9004)

This commit is contained in:
Peter Johnson
2026-06-21 19:13:33 -07:00
committed by GitHub
parent 678176cd3c
commit edbf2db5a7
12 changed files with 150 additions and 89 deletions

View File

@@ -2,13 +2,35 @@
// 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 <gtest/gtest.h>
#include <string_view>
#include <catch2/catch_session.hpp>
#include <catch2/catch_test_macros.hpp>
#include "wpi/hal/HAL.h"
int main(int argc, char** argv) {
HAL_Initialize(500, 0);
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
namespace {
bool IsCatchListCommand(int argc, char** argv) {
for (int i = 1; i < argc; ++i) {
std::string_view arg{argv[i]};
if (arg == "--list-tests" || arg == "--list-tags" ||
arg == "--list-reporters" || arg == "--list-listeners") {
return true;
}
}
return false;
}
} // namespace
TEST_CASE("HALSimDSSocket RuntimeType", "[simulation][halsim_ds_socket]") {
CHECK(HAL_RuntimeType::HAL_RUNTIME_SIMULATION == HAL_GetRuntimeType());
}
int main(int argc, char** argv) {
if (!IsCatchListCommand(argc, argv)) {
HAL_Initialize(500, 0);
}
return Catch::Session().run(argc, argv);
}