PetFlag system now functioning correctly

This commit is contained in:
jadebenn
2023-12-15 14:36:27 -06:00
parent e01fbfcc64
commit 9add2c944e
3 changed files with 70 additions and 46 deletions

View File

@@ -22,9 +22,7 @@ protected:
petComponent = baseEntity->AddComponent<PetComponent>(1);
// Initialize some values to be not default
petComponent->SetStatus(0);
petComponent->SetPetAiState(PetAiState::spawn);
petComponent->SetAbility(ePetAbilityType::Invalid);
}
void TearDown() override {
@@ -34,11 +32,14 @@ protected:
};
TEST_F(PetTest, PlacementNewAddComponentTest) {
// Test adding component
ASSERT_NE(petComponent, nullptr);
baseEntity->AddComponent<PetComponent>(1);
ASSERT_NE(baseEntity->GetComponent<PetComponent>(), nullptr);
// Test getting initial status
ASSERT_EQ(petComponent->GetParent()->GetObjectID(), 15);
ASSERT_EQ(petComponent->GetStatus(), PetFlag::NONE);
ASSERT_TRUE(petComponent->HasFlag(NONE));
ASSERT_EQ(petComponent->GetPetAiState(), PetAiState::spawn);
ASSERT_EQ(petComponent->GetAbility(), ePetAbilityType::Invalid);
}
@@ -47,12 +48,36 @@ TEST_F(PetTest, PlacementNewAddComponentTest) {
* Test bitset pet flags
*/
TEST_F(PetTest, PetComponentFlagTest) {
// Test setting and reading single flags
// Test setting and reading single flags, exclusively
petComponent->SetOnlyFlag(NONE);
ASSERT_TRUE(petComponent->HasOnlyFlag(NONE));
petComponent->SetOnlyFlag(TAMEABLE);
ASSERT_TRUE(petComponent->HasOnlyFlag(TAMEABLE));
ASSERT_FALSE(petComponent->HasOnlyFlag(SPAWNING));
// Test setting and reading multiple flags, exclusively
petComponent->SetOnlyFlag(NOT_WAITING, SPAWNING);
ASSERT_FALSE(petComponent->HasFlag(TAMEABLE));
ASSERT_TRUE(petComponent->HasFlag(NOT_WAITING));
ASSERT_TRUE(petComponent->HasFlag(SPAWNING));
ASSERT_TRUE(petComponent->HasFlag(NOT_WAITING, SPAWNING));
ASSERT_FALSE(petComponent->HasOnlyFlag(NOT_WAITING));
ASSERT_FALSE(petComponent->HasOnlyFlag(SPAWNING));
ASSERT_TRUE(petComponent->HasOnlyFlag(NOT_WAITING, SPAWNING));
// Test flags are being properly reset for next batch of tests
petComponent->SetOnlyFlag(NONE);
ASSERT_TRUE(petComponent->HasFlag(NONE));
ASSERT_TRUE(petComponent->HasOnlyFlag(NONE));
ASSERT_FALSE(petComponent->HasFlag(NOT_WAITING));
ASSERT_FALSE(petComponent->HasFlag(NOT_WAITING, SPAWNING, TAMEABLE));
// Test setting and reading single flags, non-exclusively
petComponent->SetFlag(NOT_WAITING);
ASSERT_TRUE(petComponent->HasFlag(NOT_WAITING));
ASSERT_FALSE(petComponent->HasFlag(SPAWNING));
// Test setting and reading multiple flags
// Test setting and reading multiple flags, non-exclusively
petComponent->SetFlag(TAMEABLE, BEING_TAMED);
ASSERT_TRUE(petComponent->HasFlag(TAMEABLE, BEING_TAMED));
ASSERT_TRUE(petComponent->HasFlag(NOT_WAITING));
@@ -61,7 +86,7 @@ TEST_F(PetTest, PetComponentFlagTest) {
ASSERT_FALSE(petComponent->HasFlag(SPAWNING));
ASSERT_FALSE(petComponent->HasFlag(SPAWNING, NOT_WAITING, TAMEABLE, BEING_TAMED));
// Test unsetting and reading multiple flags
// Test unsetting and reading multiple flags, non-exclusively
petComponent->UnsetFlag(NOT_WAITING, SPAWNING);
ASSERT_FALSE(petComponent->HasFlag(NOT_WAITING, SPAWNING));
ASSERT_FALSE(petComponent->HasFlag(NOT_WAITING));