Skip to content

gtest#63

Merged
Josh Robbins (jrobbins11) merged 2 commits intomainfrom
feature/gtest
Apr 21, 2026
Merged

gtest#63
Josh Robbins (jrobbins11) merged 2 commits intomainfrom
feature/gtest

Conversation

@jrobbins11
Copy link
Copy Markdown
Contributor

switching to the gtest framework

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_assert usage with TEST/TEST_F test cases and EXPECT_*/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";
@jrobbins11 Josh Robbins (jrobbins11) merged commit 8f9652e into main Apr 21, 2026
11 checks passed
@jrobbins11 Josh Robbins (jrobbins11) deleted the feature/gtest branch April 21, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants