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

Added a test suite for the Plane object. #44492

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

cabinboy1031
Copy link
Contributor

Some parts are not implemented as I don't know how to test for the Variant bindings. This is also my first go at contributing as well, and i am not quite sure if the values i chose as test inputs and outputs are useful for the context of the class. It definitely needs tweaking and finishing up by someone with knowledge in vector math to give more helpful values.

@YeldhamDev
Copy link
Member

Please remove the empty lines shown here: https://github.com/godotengine/godot/pull/44492/checks?check_run_id=1576158367

When you're done, squash your commits following these instructions: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html#the-interactive-rebase

And thank you for your first contribution! 🎉

@YeldhamDev
Copy link
Member

@cabinboy1031 cabinboy1031 force-pushed the plane-test branch 2 times, most recently from 03858ff to 7350c25 Compare December 18, 2020 19:44
Comment on lines 148 to 149
// Intersection functions need a pointer of a vector to modify
Vector3 *vec_out = new Vector3();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be rewritten to:

Suggested change
// Intersection functions need a pointer of a vector to modify
Vector3 *vec_out = new Vector3();
Vector3 vec_out;

And then use the variable by passing an address (&vec_out):

plane.intersect_3(y_facing_plane, z_facing_plane, &vec_out),

This way, there's no need to worry about delete afterward.

Also, if you do need to use new, Godot uses memnew macro instead (along with memdelete), used to better track memory.


CHECK_MESSAGE(
plane.get_normal().is_equal_approx(Vector3(32, 22, 16)),
"get_normal() should return the expected value.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless the assertion is not obvious or requires some preparation steps (complex), I don't find it necessary to repeat what it does in words, so I'd just use plain CHECK macro in those cases, the testing framework is smart enough to showcase what are the actual and expected values.

Otherwise this adds too much verbosity, in my opinion.

But I realize this is already the case as seen in some other test suites. It's fine to have those messages. Perhaps documentation should also provide an objective criteria to elaborate what kind of assertions require to use either CHECK or CHECK_MESSAGE.

@Calinou Calinou added this to the 4.0 milestone Jan 5, 2021
@cabinboy1031 cabinboy1031 requested a review from a team as a code owner July 5, 2022 10:52
Added tests for intersection and plane-point methods.
@akien-mga
Copy link
Member

Sorry for the delay further reviewing this. This seems like a good base for a Plane test suite, so let's get it merged. I rebased and amended the commit to address past review comments, and improve language/punctuation in some messages.

@akien-mga akien-mga merged commit f088c9a into godotengine:master Jul 5, 2022
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants