Skip to content

Comments

Fixed bug in transfer_state and added tests for it#75

Open
dipeshkaphle wants to merge 3 commits intomasterfrom
transfer_state_bug_fix
Open

Fixed bug in transfer_state and added tests for it#75
dipeshkaphle wants to merge 3 commits intomasterfrom
transfer_state_bug_fix

Conversation

@dipeshkaphle
Copy link
Contributor

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

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
}
};

TEST_F(TransferStateTest, convertToPlayerStateTest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Test for map, flag_offsets and scores too.
Tests by default should include all members, data and methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add

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.

2 participants