Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Athena Z <[email protected]>
  • Loading branch information
athenaz2 committed Aug 16, 2024
1 parent 091bac6 commit eca40a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ unsigned int Ogre2Scene::ShadowTextureSize(LightType _lightType) const
case LightType::EMPTY:
gzerr << "Invalid light type [" << static_cast<int>(_lightType) << "]"
<< std::endl;
return 0;
return 0u;
}
}

Expand Down
11 changes: 11 additions & 0 deletions test/common_test/Scene_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,17 +766,28 @@ TEST_F(SceneTest, ShadowTextureSize)
// Currently only support setting shadow texture size for
// directional light
// If set shadow texture size for other light types, it is ignored
auto spotLight = scene->CreateSpotLight("spot_light");
auto pointLight = scene->CreatePointLight("point_light");

EXPECT_FALSE(scene->SetShadowTextureSize(LightType::POINT, 4096u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::POINT), 2048u);

EXPECT_FALSE(scene->SetShadowTextureSize(LightType::SPOT, 4096u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::SPOT), 2048u);

EXPECT_FALSE(scene->SetShadowTextureSize(LightType::EMPTY, 4096u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::EMPTY), 0u);

// If set shadow texture size to a valid value, change it
EXPECT_TRUE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 8192u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u);

// If set shadow texture size to an invalid value, use default
EXPECT_FALSE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 1000u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u);

// If set shadow texture size to a value larger than maxTexSize,
// use default
EXPECT_FALSE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 32768u));
EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u);
}

0 comments on commit eca40a8

Please sign in to comment.