Skip to content

algo_test_*: Use gUnit parameterized tests#11

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
copybara/888525876
Open

algo_test_*: Use gUnit parameterized tests#11
copybara-service[bot] wants to merge 1 commit intomainfrom
copybara/888525876

Conversation

@copybara-service
Copy link

algo_test_*: Use gUnit parameterized tests

algo_test.h and algo_test.cc were originally implemented with custom
monolithic test classes (WeightedTester, UnweightedTester) and giant
methods (TestRational, TestOptimize, etc.) that ran in a manual loop.

This change modernizes the algorithmic regression tests by:

  • Migrating the manual testing harness to GUnit's TYPED_TEST_P.
  • Splitting the monolithic tests into 7 logical, focused test suites:
    RationalTest, MapTest, ComposeTest, SortTest, OptimizeTest,
    SearchTest, and UnweightedTest.
  • Breaking down the giant test functions into dozens of fine-grained,
    isolated test cases (e.g., OptimizeTest.RmEpsilonDestructive).
  • Preserving the original scoping and algorithmic validations while fixing
    semiring property checks with if constexpr.
  • Replacing the custom main() runner in algo_test.cc with standard
    INSTANTIATE_TYPED_TEST_SUITE_P and RUN_ALL_TESTS().
  • Verified through diffing of all VLOG and EXPECT_ macros that no test
    cases, properties, or algorithms were dropped during the migration.

This will allow the monolithic algo_test.h to be split up if we want.

algo_test_* has many very small test cases, so running them separately
via gtest_discover_tests is actually about 5 seconds slower (74s vs 69s
to run tests). Leave it as add_test().

At least it's easier to see where failures happen this way.

`algo_test.h` and `algo_test.cc` were originally implemented with custom
monolithic test classes (`WeightedTester`, `UnweightedTester`) and giant
methods (`TestRational`, `TestOptimize`, etc.) that ran in a manual loop.

This change modernizes the algorithmic regression tests by:
* Migrating the manual testing harness to GUnit's `TYPED_TEST_P`.
* Splitting the monolithic tests into 7 logical, focused test suites:
  `RationalTest`, `MapTest`, `ComposeTest`, `SortTest`, `OptimizeTest`,
  `SearchTest`, and `UnweightedTest`.
* Breaking down the giant test functions into dozens of fine-grained,
  isolated test cases (e.g., `OptimizeTest.RmEpsilonDestructive`).
* Preserving the original scoping and algorithmic validations while fixing
  semiring property checks with `if constexpr`.
* Replacing the custom `main()` runner in `algo_test.cc` with standard
  `INSTANTIATE_TYPED_TEST_SUITE_P` and `RUN_ALL_TESTS()`.
* Verified through diffing of all VLOG and EXPECT_ macros that no test
  cases, properties, or algorithms were dropped during the migration.

This will allow the monolithic algo_test.h to be split up if we want.

algo_test_* has many very small test cases, so running them separately
via gtest_discover_tests is actually about 5 seconds slower (74s vs 69s
to run tests).  Leave it as add_test().

At least it's easier to see where failures happen this way.

PiperOrigin-RevId: 888525876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant