-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
More object unit tests #44387
More object unit tests #44387
Conversation
|
||
TEST_CASE("[Object] IAPI methods") { | ||
Object object; | ||
bool *rvalid = memnew(bool(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this adds unnecessary complexity, I'd rewrite this to:
bool *rvalid = memnew(bool(false)); | |
bool valid = false; |
and then pass the pointer to methods which use this variable, such as below:
object.get_indexed(p_names, &valid);
Also, this way you don't have to dereference the pointer (*valid
) whenever you need to reset the valid
variable for other assertions.
Object object; | ||
bool *rvalid = memnew(bool(false)); | ||
|
||
object.set(StringName("script"), "script_source", rvalid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure but I think there's no need to explicitly convert the first argument to StringName
:
object.set(StringName("script"), "script_source", rvalid); | |
object.set("script", "script_source", rvalid); |
The same applies to other assertions.
*rvalid == false, | ||
"set_indexed() should update the passed bool to the expected value for empty Vector<StringName>."); | ||
|
||
*rvalid = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity check: should this be reset to false
(at least for consistency)?
*rvalid = true; | |
*rvalid = false; |
Sorry for the late review. This was at least partially superseded by #45411. If there are some parts tested here which are not covered in the latest version they might be worth sending as a new PR based on the latest |
Hello, this is my first pull request so any suggested changes or constructive criticism will be much-appreciated. I tried building off of the existing unit tests for the object class.
I added two test cases. One is a brief test of the setter and getter methods of the script interface of the Object class. The second runs through some tests of a number of methods including setters and getters in the IAPI interface of the Object class. One missing case regarding the get_indexed() and set_indexed() methods is for Vector arguments of size greater than 1. I had some trouble getting the methods to update r_valid to true in this case.