algo_test_*: Use gUnit parameterized tests#11
Open
copybara-service[bot] wants to merge 1 commit intomainfrom
Open
algo_test_*: Use gUnit parameterized tests#11copybara-service[bot] wants to merge 1 commit intomainfrom
copybara-service[bot] wants to merge 1 commit intomainfrom
Conversation
2ac92ab to
d357400
Compare
`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
d357400 to
8232f62
Compare
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.
algo_test_*: Use gUnit parameterized tests
algo_test.handalgo_test.ccwere originally implemented with custommonolithic test classes (
WeightedTester,UnweightedTester) and giantmethods (
TestRational,TestOptimize, etc.) that ran in a manual loop.This change modernizes the algorithmic regression tests by:
TYPED_TEST_P.RationalTest,MapTest,ComposeTest,SortTest,OptimizeTest,SearchTest, andUnweightedTest.isolated test cases (e.g.,
OptimizeTest.RmEpsilonDestructive).semiring property checks with
if constexpr.main()runner inalgo_test.ccwith standardINSTANTIATE_TYPED_TEST_SUITE_PandRUN_ALL_TESTS().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.