diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 4039befa..00000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/bin/gcc", - "cStandard": "c17", - "cppStandard": "gnu++17", - "intelliSenseMode": "linux-gcc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 06036ff9..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files.associations": { - "ostream": "cpp", - "stdexcept": "cpp", - "cmath": "cpp" - } -} \ No newline at end of file diff --git a/src/Color.cc b/src/Color.cc index 27ffc08d..8af1ffbd 100644 --- a/src/Color.cc +++ b/src/Color.cc @@ -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(this))[_index]; } ////////////////////////////////////////////////// diff --git a/src/Color_TEST.cc b/src/Color_TEST.cc index 87369c5e..fa1b5117 100644 --- a/src/Color_TEST.cc +++ b/src/Color_TEST.cc @@ -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; @@ -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])); } + + diff --git a/src/python_pybind11/test/Color_TEST.py b/src/python_pybind11/test/Color_TEST.py index 2cc42560..f14dcf62 100644 --- a/src/python_pybind11/test/Color_TEST.py +++ b/src/python_pybind11/test/Color_TEST.py @@ -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