[FEAT] Use CPM and catch2 has library
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "core/tuple.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "core/color.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "renderer/canvas.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
@@ -180,7 +182,7 @@ SCENARIO("Rotating a point around the x axis", "[features/transformations.featur
|
||||
Matrix full_quarter = Matrix::rotation_x(std::numbers::pi / 2);
|
||||
THEN("half_quarter * p = point(0, sqrt(2) / 2, sqrt(2) / 2)")
|
||||
{
|
||||
REQUIRE(half_quarter * p == Tuple::Point(0, sqrt(2) / 2, sqrt(2) / 2));
|
||||
REQUIRE(half_quarter * p == Tuple::Point(0, std::sqrt(2) / 2, std::sqrt(2) / 2));
|
||||
}
|
||||
AND_THEN("full_quarter * p == point(0, 0, 1)")
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
@@ -629,7 +631,7 @@ SCENARIO("Constructing a ray when the camera is transformed", "[features/camera.
|
||||
}
|
||||
AND_THEN("r.direction = vector(sqrt(2) / 2, 0, -sqrt(2) / 2)")
|
||||
{
|
||||
REQUIRE(r.direction() == Tuple::Vector(sqrt(2) / 2, 0, -sqrt(2) / 2));
|
||||
REQUIRE(r.direction() == Tuple::Vector(std::sqrt(2) / 2, 0, -std::sqrt(2) / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <external/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
|
||||
34
tests/13_cylinders.cpp
Normal file
34
tests/13_cylinders.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* 13_cylinders.cpp
|
||||
*
|
||||
* Copyright (c) 2015-2024, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* @Author: NADAL Jean-Baptiste
|
||||
* @Date: 18/03/2024
|
||||
*
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "raytracing.h"
|
||||
|
||||
using namespace Raytracer;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
project(raytracing_test)
|
||||
|
||||
CPMAddPackage("gh:catchorg/Catch2@3.5.3")
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@@ -23,10 +25,11 @@ add_executable(raytracing_test
|
||||
10_patterns.cpp
|
||||
11_reflection_refraction.cpp
|
||||
12_cubes.cpp
|
||||
13_cylinders.cpp
|
||||
)
|
||||
|
||||
include_directories("${CMAKE_SOURCE_DIR}/tests")
|
||||
|
||||
target_link_libraries(raytracing_test PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(raytracing_test PRIVATE raytracing Catch2WithMain OpenMP::OpenMP_CXX)
|
||||
|
||||
add_test(NAME raytracing_test COMMAND tests/raytracing_test)
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
#define CATCH_INTERNAL_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#define CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "external/catch.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
Reference in New Issue
Block a user