Skip to content

Commit

Permalink
Tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Kaleta committed Jun 4, 2023
1 parent 7a5a18f commit 0001889
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(TEST_DIR "${PROJECT_SOURCE_DIR}/test")
set(OUTPUT_DIR "${PROJECT_SOURCE_DIR}/buildOut")
set(EXE_OUTPUT_DIR "${OUTPUT_DIR}/bin")
set(TEST_EXE_OUTPUT_DIR "${OUTPUT_DIR}/test")
set(LIB_OUTPUT_DIR "${OUTPUT_DIR}/dist")
set(DOCS_OUTPUT_DIR "${OUTPUT_DIR}/docs")

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {

options {
skipDefaultCheckout true
timeout(time: 45, unit: 'MINUTES')
timeout(time: 20, unit: 'MINUTES')
buildDiscarder logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')
}

Expand Down
2 changes: 2 additions & 0 deletions include/algolib/geometry/dim2/vector_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ namespace algolib::geometry::dim2

bool operator==(const vector_2d & v1, const vector_2d & v2);
bool operator!=(const vector_2d & v1, const vector_2d & v2);
vector_2d operator+(vector_2d v);
vector_2d operator-(vector_2d v);
vector_2d operator+(vector_2d v1, const vector_2d & v2);
vector_2d operator-(vector_2d v1, const vector_2d & v2);
vector_2d operator*(vector_2d v, double c);
Expand Down
2 changes: 2 additions & 0 deletions include/algolib/geometry/dim3/vector_3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ namespace algolib::geometry::dim3

bool operator==(const vector_3d & v1, const vector_3d & v2);
bool operator!=(const vector_3d & v1, const vector_3d & v2);
vector_3d operator+(vector_3d v);
vector_3d operator-(vector_3d v);
vector_3d operator+(vector_3d v1, const vector_3d & v2);
vector_3d operator-(vector_3d v1, const vector_3d & v2);
vector_3d operator*(vector_3d v, double c);
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set(TEST_SOURCES
"${TEXT_TEST_SOURCES}")

# OUTPUT
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${EXE_OUTPUT_DIR}/test")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${TEST_EXE_OUTPUT_DIR}")
foreach(testsource ${TEST_SOURCES})
get_filename_component(testexec ${testsource} NAME_WE)
add_executable(${testexec} ${testsource})
Expand Down
18 changes: 18 additions & 0 deletions test/geometry/dim2/vector_2d_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ TEST(Vector2DTest, length_ThenLengthOfVector)
EXPECT_NEAR(10.0, result, offset);
}

TEST(Vector2DTest, plus_ThenCopy)
{
// given
alge2::vector_2d vec(5.4, -9.0);
// when
alge2::vector_2d result = +vec;
// then
EXPECT_EQ(vec, result);
}

TEST(Vector2DTest, minus_ThenNegateEachCoordinate)
{
// when
alge2::vector_2d result = -alge2::vector_2d(5.4, -9.0);
// then
EXPECT_EQ(alge2::vector_2d(-5.4, 9.0), result);
}

TEST(Vector2DTest, add_ThenAddEachCoordinate)
{
// when
Expand Down
18 changes: 18 additions & 0 deletions test/geometry/dim3/vector_3d_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ TEST(Vector3DTest, length_ThenLengthOfVector)
EXPECT_NEAR(23.0, result, offset);
}

TEST(Vector3DTest, plus_ThenCopy)
{
// given
alge3::vector_3d vec(5.4, 9.0, -12.3);
// when
alge3::vector_3d result = +vec;
// then
EXPECT_EQ(vec, result);
}

TEST(Vector3DTest, minus_ThenNegateEachCoordinate)
{
// when
alge3::vector_3d result = -alge3::vector_3d(5.4, 9.0, -12.3);
// then
EXPECT_EQ(alge3::vector_3d(-5.4, -9.0, 12.3), result);
}

TEST(Vector3DTest, add_ThenAddEachCoordinate)
{
// when
Expand Down

0 comments on commit 0001889

Please sign in to comment.