Working on adding test for the shape object.
This commit is contained in:
BIN
output/ch8_test.png
Normal file
BIN
output/ch8_test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@@ -4,7 +4,8 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(TESTS_SRC tuple_test.cpp colour_test.cpp canvas_test.cpp matrix_test.cpp transformation_test.cpp ray_test.cpp
|
||||
intersect_test.cpp sphere_test.cpp light_test.cpp material_test.cpp world_test.cpp camera_test.cpp)
|
||||
intersect_test.cpp sphere_test.cpp light_test.cpp material_test.cpp world_test.cpp camera_test.cpp
|
||||
shape_test.cpp)
|
||||
|
||||
add_executable(testMyRays)
|
||||
target_include_directories(testMyRays PUBLIC ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
||||
|
||||
45
tests/shape_test.cpp
Normal file
45
tests/shape_test.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* DoRayMe - a quick and dirty Raytracer
|
||||
* Shape unit tests
|
||||
*
|
||||
* Created by Manoël Trapier
|
||||
* Copyright (c) 2020 986-Studio.
|
||||
*
|
||||
*/
|
||||
#include <shape.h>
|
||||
#include <matrix.h>
|
||||
#include <transformation.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(ShapeTest, The_default_transformation)
|
||||
{
|
||||
Shape s = Shape();
|
||||
ASSERT_EQ(s.transformMatrix, Matrix4().identity());
|
||||
}
|
||||
|
||||
TEST(ShapeTest, Assigning_a_transformation)
|
||||
{
|
||||
Shape s = Shape();
|
||||
|
||||
s.setTransform(translation(2, 3, 4));
|
||||
|
||||
ASSERT_EQ(s.transformMatrix, translation(2, 3, 4));
|
||||
}
|
||||
|
||||
TEST(ShapeTest, The_default_material)
|
||||
{
|
||||
Shape s = Shape();
|
||||
|
||||
ASSERT_EQ(s.material, Material());
|
||||
}
|
||||
|
||||
TEST(ShapeTest, Assigning_a_material)
|
||||
{
|
||||
Shape s = Shape();
|
||||
Material m = Material();
|
||||
m.ambient = 1;
|
||||
|
||||
s.material = m;
|
||||
|
||||
ASSERT_EQ(s.material, m);
|
||||
}
|
||||
Reference in New Issue
Block a user