Skip to content

Commit

Permalink
Applying changes
Browse files Browse the repository at this point in the history
Signed-off-by: Avisheet <[email protected]>
  • Loading branch information
Avisheet committed Mar 6, 2024
1 parent c7b287d commit 39a5c15
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 57 deletions.
16 changes: 0 additions & 16 deletions .vscode/c_cpp_properties.json

This file was deleted.

7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

17 changes: 1 addition & 16 deletions src/Color.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,7 @@ void Color::SetFromYUV(const float _y, const float _u, const float _v)
//////////////////////////////////////////////////
float& Color::operator[](const unsigned int _index)
{
switch (_index)
{
case 0:
return this->r;
case 1:
return this->g;
case 2:
return this->b;
case 3:
return this->a;
default:
break;
}

std::cerr << "Trying to read index " << _index << " of Color" << std::endl;
throw std::runtime_error("Index Error: Color index out of range");
return (*static_cast<Color *>(this))[_index];
}

//////////////////////////////////////////////////
Expand Down
21 changes: 4 additions & 17 deletions src/Color_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ TEST(Color, Color)
EXPECT_FLOAT_EQ(0.5f, clr[1]);
EXPECT_FLOAT_EQ(1.0f, clr[2]);
EXPECT_FLOAT_EQ(1.0f, clr[3]);
// EXPECT_TRUE(std::isnan(clr[4]));
EXPECT_TRUE(std::isnan(clr[4]));

clr.R() = 0.1f;
clr.G() = 0.2f;
Expand Down Expand Up @@ -445,20 +445,7 @@ TEST(Color, OperatorIndex){
EXPECT_FLOAT_EQ(clr[1], 0.2f);
EXPECT_FLOAT_EQ(clr[2], 0.3f);
EXPECT_FLOAT_EQ(clr[3], 0.4f);

// const math::Color constClr = clr;

// // this tests _that_ the expected exception is thrown
EXPECT_THROW({
try
{
clr[4] = 0.1f;
}
catch( const std::runtime_error& e )
{
// and this tests that it has the correct message
EXPECT_STREQ( "Index Error: Color index out of range", e.what() );
throw;
}
}, std::runtime_error);
EXPECT_TRUE(std::isnan(clr[4]));
}


2 changes: 1 addition & 1 deletion src/python_pybind11/test/Color_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_color(self):
self.assertAlmostEqual(0.5, clr[1])
self.assertAlmostEqual(1.0, clr[2])
self.assertAlmostEqual(1.0, clr[3])
# self.assertTrue(math.isnan(clr[4]))
self.assertTrue(math.isnan(clr[4]))

clr.set(0.1, 0.2, 0.3, 0.4)
clr = clr + 0.2
Expand Down

0 comments on commit 39a5c15

Please sign in to comment.