diff --git a/raytracing/src/canvas.cpp b/raytracing/src/canvas.cpp index 2c9caf1..77a0d65 100644 --- a/raytracing/src/canvas.cpp +++ b/raytracing/src/canvas.cpp @@ -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>(m_width, std::vector(m_height)); diff --git a/raytracing/src/canvas.h b/raytracing/src/canvas.h index 9bb18cd..743824c 100644 --- a/raytracing/src/canvas.h +++ b/raytracing/src/canvas.h @@ -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; diff --git a/raytracing/src/intersections.cpp b/raytracing/src/intersections.cpp index 27c274e..80f96e5 100644 --- a/raytracing/src/intersections.cpp +++ b/raytracing/src/intersections.cpp @@ -45,7 +45,8 @@ Intersections::Intersections(const std::initializer_list &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; } diff --git a/tests/05_rays.cpp b/tests/05_rays.cpp index acf785a..ed0a0b9 100644 --- a/tests/05_rays.cpp +++ b/tests/05_rays.cpp @@ -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))")