gtest#63
Merged
Josh Robbins (jrobbins11) merged 2 commits intomainfrom Apr 21, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the C++ test suite from a custom test_assert + bespoke main() style to the GoogleTest (gtest) framework, and updates the build system to fetch/link gtest when needed.
Changes:
- Replaced
test_assertusage withTEST/TEST_Ftest cases andEXPECT_*/ASSERT_*assertions across the C++ tests. - Added gtest dependency wiring in CMake (find system GTest or FetchContent googletest v1.14.0; link tests to
GTest::gtest). - Refactored some tests into multiple gtest test cases and introduced fixtures where appropriate (e.g., JSON temp-dir setup/teardown).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/cpp-tests/src/test_vrep_2_hybzono.cpp | Converted to gtest TEST and added per-binary gtest main() with test-data dir arg handling. |
| test/cpp-tests/src/test_support.cpp | Converted to gtest with two TESTs and gtest assertions. |
| test/cpp-tests/src/test_safety_verification.cpp | Converted to gtest TEST and added gtest main(). |
| test/cpp-tests/src/test_remove_redundancy.cpp | Converted multiple cases to gtest TESTs; refactored random test into looped gtest assertions; retains arg-based test data loading for file-based cases. |
| test/cpp-tests/src/test_point_contain.cpp | Split into two gtest TESTs for inside/outside point checks; added gtest main(). |
| test/cpp-tests/src/test_overapproximation.cpp | Converted overapproximation checks to gtest TESTs with ASSERT_* guards for test-data dir. |
| test/cpp-tests/src/test_operator_overloading.cpp | Converted operator checks into multiple gtest TESTs and refactored shared setup into a helper. |
| test/cpp-tests/src/test_minkowski_sum.cpp | Converted to gtest TEST and added gtest main(). |
| test/cpp-tests/src/test_json.cpp | Introduced TEST_F fixture to manage temp directory via SetUp/TearDown; migrated assertions to gtest. |
| test/cpp-tests/src/test_is_empty.cpp | Split into two gtest TESTs for feasible/infeasible cases; added gtest main(). |
| test/cpp-tests/src/test_interval_arithmetic.cpp | Converted to gtest with multiple TESTs and migrated exponent test to gtest assertions/exception checks. |
| test/cpp-tests/src/test_intersection.cpp | Converted to gtest TEST and added gtest main(). |
| test/cpp-tests/src/test_get_leaves.cpp | Converted leaf-count check to gtest TEST and added gtest main(). |
| test/cpp-tests/src/test_affine_inclusion.cpp | Converted to gtest TEST and added gtest main(). |
| test/cpp-tests/include/unit_test_utilities.hpp | Added <gtest/gtest.h> include and removed custom test_assert. |
| test/CMakeLists.txt | Links test executables with GTest::gtest and includes GoogleTest module. |
| CMakeLists.txt | Adds GTest discovery/fetching under BUILD_TESTING using find_package(GTest) or FetchContent googletest v1.14.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static std::string g_test_data_dir; | ||
|
|
||
| TEST(VRep2HybZono, MatchesExpected) | ||
| { |
| static std::string g_test_data_dir; | ||
|
|
||
| TEST(MinkowskiSum, MatchesExpected) | ||
| { |
| static std::string g_test_data_dir; | ||
|
|
||
| TEST(Intersection, MatchesExpected) | ||
| { |
Comment on lines
+8
to
+25
| TEST(IsEmpty, FeasibleIsNotEmpty) | ||
| { | ||
| // input: directory where unit test data resides | ||
| if (argc < 2) | ||
| { | ||
| std::cerr << "Usage: " << argv[0] << " <test data folder>" << std::endl; | ||
| return 1; | ||
| } | ||
| std::string test_folder = argv[1]; | ||
| test_folder += "/is_empty/"; | ||
|
|
||
| // load in feasible conzono | ||
| Eigen::SparseMatrix<zono_float> G, A; | ||
| Eigen::Vector<zono_float, -1> c, b; | ||
| G = load_sparse_matrix(test_folder + "f_G.txt"); | ||
| c = load_vector(test_folder + "f_c.txt"); | ||
| A = load_sparse_matrix(test_folder + "f_A.txt"); | ||
| b = load_vector(test_folder + "f_b.txt"); | ||
| const std::string test_folder = g_test_data_dir + "/is_empty/"; | ||
|
|
||
| const Eigen::SparseMatrix<zono_float> G = load_sparse_matrix(test_folder + "f_G.txt"); | ||
| const Eigen::Vector<zono_float, -1> c = load_vector(test_folder + "f_c.txt"); | ||
| const Eigen::SparseMatrix<zono_float> A = load_sparse_matrix(test_folder + "f_A.txt"); | ||
| const Eigen::Vector<zono_float, -1> b = load_vector(test_folder + "f_b.txt"); | ||
|
|
||
| const ConZono Zf (G, c, A, b); | ||
|
|
||
| // load in infeasible conzono | ||
| G = load_sparse_matrix(test_folder + "i_G.txt"); | ||
| c = load_vector(test_folder + "i_c.txt"); | ||
| A = load_sparse_matrix(test_folder + "i_A.txt"); | ||
| b = load_vector(test_folder + "i_b.txt"); | ||
| EXPECT_FALSE(Zf.is_empty()) << "Expected Zf to be non-empty"; | ||
| } | ||
|
|
||
| TEST(IsEmpty, InfeasibleIsEmpty) | ||
| { | ||
| const std::string test_folder = g_test_data_dir + "/is_empty/"; | ||
|
|
Comment on lines
+8
to
11
| TEST(Support, ConZonoSupportValue) | ||
| { | ||
| // input: directory where unit test data resides | ||
| if (argc < 2) | ||
| { | ||
| std::cerr << "Usage: " << argv[0] << " <test data folder>" << std::endl; | ||
| return 1; | ||
| } | ||
| std::string test_folder = argv[1]; | ||
| test_folder += "/support/"; | ||
| const std::string test_folder = g_test_data_dir + "/support/"; | ||
|
|
Comment on lines
+8
to
+11
| TEST(PointContain, ContainsInternalPoint) | ||
| { | ||
| // input: directory where unit test data resides | ||
| if (argc < 2) | ||
| { | ||
| std::cerr << "Usage: " << argv[0] << " <test data folder>" << std::endl; | ||
| return 1; | ||
| } | ||
| std::string test_folder = argv[1]; | ||
| test_folder += "/point_contain/"; | ||
|
|
||
| // load in conzono | ||
| const std::string test_folder = g_test_data_dir + "/point_contain/"; | ||
|
|
Comment on lines
+74
to
+75
| EXPECT_THROW(a.pow(456./123.), std::domain_error) | ||
| << "Expected fractional power of negative interval to throw"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
switching to the gtest framework