diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt index 2b5fa65e139..e2b95883c46 100644 --- a/wpimath/CMakeLists.txt +++ b/wpimath/CMakeLists.txt @@ -277,8 +277,22 @@ configure_file(wpimath-config.cmake.in ${WPILIB_BINARY_DIR}/wpimath-config.cmake install(FILES ${WPILIB_BINARY_DIR}/wpimath-config.cmake DESTINATION share/wpimath) install(EXPORT wpimath DESTINATION share/wpimath) -if(WITH_TESTS) - wpilib_add_test(wpimath src/test/native/cpp) - target_include_directories(wpimath_test PRIVATE src/test/native/include) - target_link_libraries(wpimath_test wpimath gmock_main) +# if(WITH_TESTS) +# wpilib_add_test(wpimath src/test/native/cpp) +# target_include_directories(wpimath_test PRIVATE src/test/native/include) +# target_link_libraries(wpimath_test wpimath gmock_main) +# endif() + +add_executable(wpimath_test2 src/test/quick_test.cpp) +if(MSVC) + target_compile_options(wpimath_test2 PRIVATE /wd4101 /wd4251) endif() +add_test(NAME wpimath COMMAND wpimath_test2) +add_custom_command( + TARGET wpimath_test2 + POST_BUILD + COMMAND echo built wpimath_test2 + VERBATIM +) +target_link_libraries(wpimath_test2 wpimath) + diff --git a/wpimath/src/test/quick_test.cpp b/wpimath/src/test/quick_test.cpp new file mode 100644 index 00000000000..eb818c40886 --- /dev/null +++ b/wpimath/src/test/quick_test.cpp @@ -0,0 +1,26 @@ +// Copyright (c) FIRST and other WPILib contributors. +// 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 "frc/system/plant/DCMotor.h" +#include "plant.pb.h" + +int main(int arc, char** argv) { + const frc::DCMotor kExpectedData = frc::DCMotor{units::volt_t{1.91}, + units::newton_meter_t{19.1}, + units::ampere_t{1.74}, + units::ampere_t{2.29}, + units::radians_per_second_t{2.2}, + 2}; + google::protobuf::Arena arena; + google::protobuf::Message* proto = wpi::Protobuf::New(&arena); + wpi::PackProtobuf(proto, kExpectedData); + frc::DCMotor unpacked_data = wpi::UnpackProtobuf(*proto); + + if (unpacked_data.nominalVoltage.value() != kExpectedData.nominalVoltage.value()) { + return 1; + } + return 0; +}