From d67f024711d8e60bd1c3f4e92a6550354207434f Mon Sep 17 00:00:00 2001 From: NADAL Jean-Baptiste Date: Thu, 15 Feb 2024 17:04:05 +0100 Subject: [PATCH] [FEAT] Add Extra Tests to update code coverage of current code. --- .vscode/settings.json | 5 ++++ tests/05_rays.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9322c9a..083b3b3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -92,5 +92,10 @@ } } } + ], + "gcovViewer.buildDirectories": [ + "/home/jbnadal/sources/jb/raytracing_challenge/build/raytracing/CMakeFiles/raytracing.dir/src", + "/home/jbnadal/sources/jb/raytracing_challenge/build/apps/CMakeFiles/chapter_05.dir", + "/home/jbnadal/sources/jb/raytracing_challenge/build/tests/CMakeFiles/raytracing_test.dir" ] } \ No newline at end of file diff --git a/tests/05_rays.cpp b/tests/05_rays.cpp index 93d45dd..acf785a 100644 --- a/tests/05_rays.cpp +++ b/tests/05_rays.cpp @@ -276,6 +276,75 @@ SCENARIO("An intersection encapsulates t and object", "[features/intersections.f /* ------------------------------------------------------------------------- */ +SCENARIO("An intersection could be affected", "[features/intersections.feature]") +{ + GIVEN("s <- sphere()") + { + Sphere s; + AND_GIVEN("i1 <- intersection(3.5,s) and i2 <- intersection()") + { + Intersection i1(3.5, s); + Intersection i2; + + WHEN("i2 <- i1") + { + i1 = i1; + i2 = i1; + THEN("i2.t = 3.5") + { + REQUIRE(i2.distance_t() == 3.5); + } + AND_THEN("i2.object = s") + { + REQUIRE(i2.object() == s); + } + } + } + } +} + +/* ------------------------------------------------------------------------- */ + +SCENARIO("Intersection could be compared", "[features/intersections.feature]") +{ + GIVEN("s <- sphere()") + { + Sphere s; + AND_GIVEN("i1 <- intersection(3,s) and i2 <- intersection(4,s)") + { + Intersection i1(3.0, s); + Intersection i2(4.0, s); + + THEN("i2 > i1") + { + REQUIRE(i2 > i1); + } + AND_THEN("i1 < i2") + { + REQUIRE(i1 < i2); + } + AND_THEN("i2 > 2") + { + REQUIRE(i2 > 2.0); + } + AND_THEN("i2 >= 4") + { + REQUIRE(i2 >= 4.0); + } + AND_THEN("i2 < 6") + { + REQUIRE(i2 < 6.0); + } + AND_THEN("i2 <= 4") + { + REQUIRE(i2 <= 4.0); + } + } + } +} + +/* ------------------------------------------------------------------------- */ + SCENARIO("Aggregating intersections", "[features/intersections.feature]") { GIVEN("s <- sphere()") @@ -420,6 +489,7 @@ SCENARIO("The hit, when all intersections have negative t", "[features/intersect THEN("i is nothing") { REQUIRE(i.is_nothing()); + REQUIRE(!i.is_defined()); } } }