[FEAT] Fix tuple and color operators
This commit is contained in:
@@ -104,6 +104,18 @@ TEST_CASE("Adding two tuples", "[Tuple][Operations]")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Adding two tuples without modify a1", "[Tuple][Operations]")
|
||||
{
|
||||
Tuple a1(3, -2, 5, 1);
|
||||
Tuple a2(-2, 3, 1, 0);
|
||||
|
||||
Tuple a3 = a1 + a2;
|
||||
|
||||
REQUIRE((a1 + a2) == Tuple(1, 1, 6, 1));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Subtracting two points", "[Tuple][Operations]")
|
||||
{
|
||||
Tuple p1 = Tuple::Point(3, 2, 1);
|
||||
@@ -114,6 +126,18 @@ TEST_CASE("Subtracting two points", "[Tuple][Operations]")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Subtracting two points without modify p1", "[Tuple][Operations]")
|
||||
{
|
||||
Tuple p1 = Tuple::Point(3, 2, 1);
|
||||
Tuple p2 = Tuple::Point(5, 6, 7);
|
||||
|
||||
Tuple p3 = p1 - p2;
|
||||
|
||||
REQUIRE((p1 - p2) == Tuple::Vector(-2, -4, -6));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Subtracting a vector from a point", "[Tuple][Operations]")
|
||||
{
|
||||
Tuple p = Tuple::Point(3, 2, 1);
|
||||
@@ -162,6 +186,17 @@ TEST_CASE("Multiplying a tuple by a scalar", "[Tuple][Multiplication]")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Multiplying a tuple by a scalar without modify a", "[Tuple][Multiplication]")
|
||||
{
|
||||
Tuple a(1, -2, 3, -4);
|
||||
|
||||
Tuple b = a * 3.5;
|
||||
|
||||
REQUIRE(a * 3.5 == Tuple(3.5, -7, 10.5, -14));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Dividing a tuple by a scalar", "[Tuple][Multiplication]")
|
||||
{
|
||||
Tuple a(1, -2, 3, -4);
|
||||
@@ -171,6 +206,17 @@ TEST_CASE("Dividing a tuple by a scalar", "[Tuple][Multiplication]")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Dividing a tuple by a scalar without modify a", "[Tuple][Multiplication]")
|
||||
{
|
||||
Tuple a(1, -2, 3, -4);
|
||||
|
||||
Tuple b = a / 2;
|
||||
|
||||
REQUIRE(a / 2 == Tuple(0.5, -1, 1.5, -2));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("Computing the magnitude of vector(1,0,0)", "[Tuple][Magnitude]")
|
||||
{
|
||||
Tuple v = Tuple::Vector(1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user