Skip to content

Commit

Permalink
comparison tolerance for ogre float values
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Jan 23, 2021
1 parent 2e37769 commit cd6e89f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Camera_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CameraTest::ViewProjectionMatrix(const std::string &_renderEngine)

EXPECT_GT(camera->AspectRatio(), 0);
camera->SetAspectRatio(1.7777);
EXPECT_DOUBLE_EQ(1.7777, camera->AspectRatio());
EXPECT_NEAR(1.7777, camera->AspectRatio(), 1e-6);

camera->SetAntiAliasing(1u);
EXPECT_EQ(1u, camera->AntiAliasing());
Expand Down
9 changes: 5 additions & 4 deletions src/Light_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ void LightTest::Light(const std::string &_renderEngine)
EXPECT_FALSE(light->CastShadows());

// attenuation
// Checking near because Ogre stores it as float
light->SetAttenuationConstant(0.6);
EXPECT_DOUBLE_EQ(0.6, light->AttenuationConstant());
EXPECT_NEAR(0.6, light->AttenuationConstant(), 1e-6);
light->SetAttenuationLinear(0.2);
EXPECT_DOUBLE_EQ(0.2, light->AttenuationLinear());
EXPECT_NEAR(0.2, light->AttenuationLinear(), 1e-6);
light->SetAttenuationQuadratic(0.01);
EXPECT_DOUBLE_EQ(0.01, light->AttenuationQuadratic());
EXPECT_NEAR(0.01, light->AttenuationQuadratic(), 1e-6);
light->SetAttenuationRange(10);
EXPECT_DOUBLE_EQ(10, light->AttenuationRange());

Expand Down Expand Up @@ -122,7 +123,7 @@ void LightTest::Light(const std::string &_renderEngine)
spotLight->SetOuterAngle(math::Angle(0.2));
EXPECT_EQ(math::Angle(0.2), spotLight->OuterAngle());
spotLight->SetFalloff(0.2);
EXPECT_DOUBLE_EQ(0.2, spotLight->Falloff());
EXPECT_NEAR(0.2, spotLight->Falloff(), 1e-6);

// remove lights
scene->DestroyLightById(light->Id());
Expand Down

0 comments on commit cd6e89f

Please sign in to comment.