Fixed bug in transfer_state and added tests for it#75
Open
dipeshkaphle wants to merge 3 commits intomasterfrom
Open
Fixed bug in transfer_state and added tests for it#75dipeshkaphle wants to merge 3 commits intomasterfrom
dipeshkaphle wants to merge 3 commits intomasterfrom
Conversation
The bug was due to not updating num_bots ,num_towers,num_enemy_towers,num_enemy_bots and num_flags in transfer_state::convertToPlayerState function. Because of it, state.num_bots wouldnt be the same as state.bots.size() in game. Similar thing happened for towers and flag
kumaran-14
requested changes
Mar 23, 2021
| } | ||
| }; | ||
|
|
||
| TEST_F(TransferStateTest, convertToPlayerStateTest) { |
Collaborator
There was a problem hiding this comment.
Capitalize first letter.
Same below.
Comment on lines
14
to
49
| TransferStateTest() : ts(), ps() { | ||
| ts.num_bots = 10; | ||
| ts.num_enemy_bots = 20; | ||
| ts.num_towers = 30; | ||
| ps.num_bots = 50; | ||
| ps.bots.assign(ps.num_bots, player_state::Bot()); | ||
| ps.num_enemy_bots = 30; | ||
| ps.enemy_bots.assign(ps.num_enemy_bots, player_state::Bot()); | ||
| } | ||
| }; | ||
|
|
||
| TEST_F(TransferStateTest, convertToPlayerStateTest) { | ||
| auto new_ps = ConvertToPlayerState(ts); | ||
|
|
||
| // non default values, changed in TransferStateTest constructor | ||
| EXPECT_EQ(new_ps.num_bots, ts.num_bots); // must equal 10 | ||
| EXPECT_EQ(new_ps.num_enemy_bots, ts.num_enemy_bots); // must equal 20 | ||
| EXPECT_EQ(new_ps.num_towers, ts.num_towers); // must equal 30 | ||
|
|
||
| // default values | ||
| EXPECT_EQ(new_ps.num_enemy_towers, ts.num_enemy_towers); | ||
| EXPECT_EQ(new_ps.num_flags, ts.num_flags); | ||
| } | ||
|
|
||
| TEST_F(TransferStateTest, convertToTransferStateTest) { | ||
| auto new_ts = ConvertToTransferState(ps); | ||
|
|
||
| // non default values, changed in TransferStateTest constructor | ||
| EXPECT_EQ(new_ts.num_bots, ps.num_bots); // equals 50 | ||
| EXPECT_EQ(new_ts.num_enemy_bots, ps.num_enemy_bots); // equals 30 | ||
|
|
||
| // default values | ||
| EXPECT_EQ(new_ts.num_towers, ps.num_towers); | ||
| EXPECT_EQ(new_ts.num_enemy_towers, ps.num_enemy_towers); | ||
| EXPECT_EQ(new_ts.num_flags, ps.num_flags); | ||
| } |
Collaborator
There was a problem hiding this comment.
Test for map, flag_offsets and scores too.
Tests by default should include all members, data and methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug was due to not updating num_bots
,num_towers,num_enemy_towers,num_enemy_bots and num_flags in
transfer_state::convertToPlayerState function. Because of it, state.num_bots wouldnt be
the same as state.bots.size() in game. Similar thing happened for towers
and flag