Add pure C++ unit tests using Google Test#5
Conversation
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
Co-authored-by: Yuri05 <25061876+Yuri05@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds direct C++ unit testing infrastructure to the OSPSuite.SimModel project using Google Test framework v1.14.0. It introduces a new test project (OSPSuite.SimModelNative.Tests) that tests C++ functionality directly without C# interop, complementing the existing C# tests.
Key changes:
- New cross-platform test project with Google Test integration (NuGet for Windows, FetchContent for Unix)
- Build script integration for automated test execution with XML output generation
- Initial test coverage for core utilities (MathHelper, ConstantFormula), data structures (ValuePoint, TObjectVector), and formula classes
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/OSPSuite.SimModelNative.Tests/CMakeLists.txt | CMake configuration for Unix builds with Google Test integration via FetchContent |
| tests/OSPSuite.SimModelNative.Tests/OSPSuite.SimModelNative.Tests.vcxproj | Visual Studio project file for Windows builds with NuGet-based Google Test dependency |
| tests/OSPSuite.SimModelNative.Tests/OSPSuite.SimModelNative.Tests.vcxproj.filters | Project filters organizing test and source files |
| tests/OSPSuite.SimModelNative.Tests/packages.config | NuGet package configuration specifying googletest 1.14.0 |
| tests/OSPSuite.SimModelNative.Tests/README.md | Comprehensive documentation for building, running, and extending tests |
| tests/OSPSuite.SimModelNative.Tests/src/MathHelperTests.cpp | Unit tests for MathHelper utilities and ConstantFormula with main() entry point |
| tests/OSPSuite.SimModelNative.Tests/src/FormulaTests.cpp | Basic constructor tests for MinFormula, MaxFormula, DivFormula, DiffFormula |
| tests/OSPSuite.SimModelNative.Tests/src/ValuePointTests.cpp | Tests for ValuePoint constructors, copy semantics, and field validation |
| tests/OSPSuite.SimModelNative.Tests/src/TObjectVectorTests.cpp | Tests for TObjectVector operations including memory management |
| buildWindows.bat | Added C++ test execution with XML output |
| buildNix.sh | Integrated C++ test building and execution in Unix build pipeline |
| OSPSuite.SimModel.sln | Added new test project to Tests solution folder with dependencies |
| _codeql_detected_source_root | CodeQL configuration file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int main(int argc, char **argv) { | ||
| ::testing::InitGoogleTest(&argc, argv); | ||
| return RUN_ALL_TESTS(); | ||
| } |
There was a problem hiding this comment.
The main() function should be removed from this test file. Google Test automatically provides a main() function when linking with gtest_main (as configured in CMakeLists.txt line 54). Having a custom main() here creates duplicate symbol conflicts during linking and is redundant.
| int main(int argc, char **argv) { | |
| ::testing::InitGoogleTest(&argc, argv); | |
| return RUN_ALL_TESTS(); | |
| } |
Existing tests are C#-only and test C++ functionality indirectly through interop. This adds direct C++ unit tests for OSPSuite.SimModelNative.
Changes
Test Infrastructure
tests/OSPSuite.SimModelNative.Testsusing Google Test v1.14.0Build Integration
Test Coverage (200+ assertions)
Example
Tests run on Windows (x64), Ubuntu (x64/ARM64), and macOS (x64/ARM64) in CI pipeline with XML output artifacts.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.