Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert axisAlignedCollision tasts to Catch2 and improve docs #15427

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JosiahWI
Copy link
Contributor

@JosiahWI JosiahWI commented Nov 12, 2024

This is just cleanup. The content of the unit tests should not be changed, although one redundant test was removed. It looked like the author copy-pasted a test, intending to change the test parameters, but forgot to change them. Since I don't know what the author intended to change, I took it back out. I have not converted the collisionMoveSimple tests that were recently added, and I do not have time to in the near future.

I have also reworded the docstring of the function under test to clarify that dtime is an inout parameter. The original wording does not seem to mention its use as an input to the function. This information came from @appgurueu, and I observed it to be correct based on the unit test behavior; I have not read the code of the function under test.

To do

Ready for Review.

How to test

luanti --run-unittests --test-module "[collision]"

@Zughy Zughy added Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements Code quality labels Nov 13, 2024
@kno10
Copy link
Contributor

kno10 commented Nov 14, 2024

#15408 adds additional collision unit tests.

@JosiahWI
Copy link
Contributor Author

@kno10 That looks great, thank you! If that lands before this one, I can rebase this over some weekend thereafter.

@JosiahWI JosiahWI force-pushed the refactor/catch2-axis-aligned-collision branch from 20d30ae to 702e7dd Compare March 17, 2025 12:38
@JosiahWI
Copy link
Contributor Author

Rebased on master. Ready for review.

Comment on lines 111 to 115
SECTION("Given a 0.5x2x1 cube translated by -2 units on the x-axis "
"and -1.5 units on the y-axis, "
"when it moves 0.5 units per step in the +x direction "
"and 0.1 units per step in the +y direction for 3 steps, "
"then it should collide on the X axis within epsilon of 3 steps.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

having throughout but hard to read textual description that duplicates the test contents looks pretty useless to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is pretty bad. I will think about how to describe the intent of the test better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took a shot at it. Is there anything else I should do to improve them?

@@ -16,15 +20,13 @@ class TestCollision : public TestBase {

void runTests(IGameDef *gamedef);

void testAxisAlignedCollision();
void testCollisionMoveSimple(IGameDef *gamedef);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we shouldn't do partial migrations so that catch and regular tests are mixed in a single file.
Or is there no solution to pass gamedef to tests yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't, yet, but maybe this is the right time to make that solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will work on a patch for that, and then we can decide whether to do that here or separately.

@sfan5 sfan5 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Mar 29, 2025
* Use `float` overload of `std::fabs` to not necessitate promotion.
* Word test descriptions to describe intent instead of method.
@JosiahWI JosiahWI force-pushed the refactor/catch2-axis-aligned-collision branch from 0e3dbb0 to cd5fcd5 Compare March 29, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) Code quality Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants