[FEAT] Update code coverage

This commit is contained in:
NADAL Jean-Baptiste
2024-02-15 18:30:44 +01:00
parent d67f024711
commit f8b94c9d0b
4 changed files with 37 additions and 9 deletions

View File

@@ -38,12 +38,6 @@ using namespace Raytracer;
/* ------------------------------------------------------------------------- */
Canvas::Canvas(void) : m_width(0), m_height(0)
{
}
/* ------------------------------------------------------------------------- */
Canvas::Canvas(uint16_t a_width, uint16_t a_height) : m_width(a_width), m_height(a_height)
{
m_pixels = std::vector<std::vector<Color>>(m_width, std::vector<Color>(m_height));

View File

@@ -42,7 +42,6 @@ namespace Raytracer
class Canvas
{
public:
Canvas(void);
Canvas(uint16_t a_width, uint16_t a_height);
uint16_t width(void) const;

View File

@@ -45,7 +45,8 @@ Intersections::Intersections(const std::initializer_list<Intersection> &a_list)
Intersections::Intersections(Intersections &an_other)
{
std::copy(an_other.m_data.begin(), an_other.m_data.end(), m_data.begin());
m_data.reserve(an_other.m_data.size());
m_data.assign(an_other.m_data.begin(), an_other.m_data.end());
}
/* ------------------------------------------------------------------------- */
@@ -64,7 +65,8 @@ const Intersections &Intersections::operator=(const Intersections &an_other)
return *this;
}
std::copy(an_other.m_data.begin(), an_other.m_data.end(), m_data.begin());
m_data.reserve(an_other.m_data.size());
m_data.assign(an_other.m_data.begin(), an_other.m_data.end());
return *this;
}

View File

@@ -379,6 +379,39 @@ SCENARIO("Aggregating intersections", "[features/intersections.feature]")
/* ------------------------------------------------------------------------- */
SCENARIO("Operations with intersections", "[features/intersections.feature]")
{
GIVEN("xs <- intersections({})")
{
Intersections xs1({});
AND_GIVEN("s <- sphere()")
{
Sphere s;
Intersection i1(1, s);
AND_GIVEN("xs2 <- intersections({i1})")
{
Intersections xs2({i1});
WHEN("xs1 <- xs2")
{
// xs2 = xs2;
xs1 = xs2;
THEN("xs1.count = 1")
{
REQUIRE(xs1.count() == 1);
}
Intersections xs3 = xs1;
THEN("xs3.count = 1")
{
REQUIRE(xs3.count() == 1);
}
}
}
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("Intersect sets the object on the intersection", "[features/spheres.feature]")
{
GIVEN("r <- ray(point(0, 0, 5), vector(0, 0, 1))")