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

Action_built: Add unittest for percentage lookup #647

Merged
merged 3 commits into from
Mar 30, 2024

Conversation

zzam
Copy link
Contributor

@zzam zzam commented Mar 29, 2024

Testing the percentage lookup code fixed some days ago.

TODO: What else to test in here? and how?

@@ -323,6 +323,10 @@ void COrder_Built::AiUnitKilled(CUnit &unit)

static std::size_t FindCFramePercent(const std::vector<CConstructionFrame> &cframes, int percent)
{
if (cframes.empty())
{
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

returning std::optional<std::size_t> might be an option. that ensures the test for validity.

.editorconfig Outdated
@@ -8,6 +8,7 @@ root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to split PR next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #648

{
const int progressOnePercent = unit.Type->Stats[0].Costs[TimeCost] * 6;
return testUpdateConstrFrame_Progress(unit, percent * progressOnePercent, initialFrame);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not formatted correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 59 to 60
void setFrames(std::vector<CConstructionFrame> &cframes,
const std::vector<std::pair<int, int>>& vec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would std::vector<CConstructionFrame> makeFrames(const std::vector<std::pair<int, int>>& vec) make sense instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed. But does not look too different.

@Jarod42 Jarod42 merged commit 8fc31ab into Wargus:master Mar 30, 2024
3 checks passed
@zzam zzam deleted the action_built_add_test branch March 30, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants