[FEAT] Color Finish all tests
This commit is contained in:
@@ -109,6 +109,20 @@ const Color Color::operator*(double a_scalar) const
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
const Color Color::operator*(const Color &a_color) const
|
||||
{
|
||||
// Using the hadamard product.
|
||||
double the_red, the_green, the_blue;
|
||||
|
||||
the_red = m_red * a_color.m_red;
|
||||
the_green = m_green * a_color.m_green;
|
||||
the_blue = m_blue * a_color.m_blue;
|
||||
|
||||
return Color(the_red, the_green, the_blue);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
const Color &Color::operator+=(const Color &a_color)
|
||||
{
|
||||
m_red += a_color.m_red;
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Raytracer
|
||||
const Color operator+(const Color &a_color) const;
|
||||
const Color operator-(const Color &a_color) const;
|
||||
const Color operator*(double a_scalar) const;
|
||||
const Color operator*(const Color &a_color) const;
|
||||
|
||||
const Color &operator+=(const Color &a_color);
|
||||
const Color &operator-=(const Color &a_color);
|
||||
|
||||
@@ -119,3 +119,14 @@ TEST_CASE("Multiplying a color by a scalar without modify c", "[Colors]")
|
||||
|
||||
REQUIRE(c * 2 == Color(0.4, 0.6, 0.8));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Multiplying a colors", "[Colors]")
|
||||
{
|
||||
Color c1(1, 0.2, 0.4);
|
||||
Color c2(0.9, 1, 0.1);
|
||||
|
||||
|
||||
REQUIRE((c1 * c2) == Color(0.9, 0.2, 0.04));
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(main_test)
|
||||
|
||||
include(CTest)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
Reference in New Issue
Block a user