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

Port OrderedHashMap tests to doctest #41117

Merged
merged 1 commit into from Aug 14, 2020
Merged

Conversation

3akev
Copy link
Contributor

@3akev 3akev commented Aug 8, 2020

No description provided.

@3akev 3akev mentioned this pull request Aug 8, 2020
10 tasks
Copy link
Contributor

@AndreaCatania AndreaCatania left a comment

Choose a reason for hiding this comment

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

Looks good, I've just a concern; check below.

}

bool test_iteration(OrderedHashMap<int, int> &map) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function make sense only when used by TEST_CASE("[OrderedHashMap] Iteration") {. I wonder if you should put directly into that function.

CHECK(test_iteration(map));
}

bool test_const_iteration(const OrderedHashMap<int, int> &map) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As the above function, I wonder if make more sense put this into the TEST_CASE("[OrderedHashMap] Const iteration") { directly.

Copy link
Contributor

@Xrayez Xrayez Aug 8, 2020

Choose a reason for hiding this comment

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

Look at ClassDB tests: #40980, there are many existing method calls like that. It's ok to call into methods within test cases. But I think it would be better if assertions are written closer to actual checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved code from each method into respective test case 👍

Comment on lines 130 to 132
if (expected[idx] != Pair<int, int>(E.key(), E.value())) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Something like that:

Suggested change
if (expected[idx] != Pair<int, int>(E.key(), E.value())) {
return false;
}
CHECK(expected[idx] != Pair<int, int>(E.key(), E.value()));

The method could be converted to void instead of returning bool.

You can also use logging methods like CAPTURE, INFO and MESSAGE, to inspect those indices for instance. See doctest parameterized tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it could probably be simplified that way. I'll see what I can do, thanks!

Copy link
Contributor

@Xrayez Xrayez left a comment

Choose a reason for hiding this comment

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

Some logging could be added for parameterized tests, but since this works I don't see why it can't be merged in its current state. 🙂

@akien-mga akien-mga merged commit c9dbe14 into godotengine:master Aug 14, 2020
@akien-mga
Copy link
Member

Thanks!

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.

None yet

5 participants