From 255698cba21bbb559c7bca635ba98b52df19797c Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Wed, 8 Jan 2020 21:57:41 +0100 Subject: [PATCH] ~ somehow forgot to link library to unitTests --- CMakeLists.txt | 1 + src/DrawRender.cpp | 3 +-- src/Rectangle.cpp | 8 ++++---- src/utils.cpp | 16 ---------------- src/utils.hpp | 5 +---- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adc7ebb..f3cfff7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ enable_testing() find_package(Catch2 REQUIRED) add_executable(UnitTests ${SOURCES} ${HEADERS} ${TESTS}) target_link_libraries(UnitTests Catch2::Catch2) +target_link_libraries(UnitTests ${LIB_PATH}/lib/liblibrary.a) include(CTest) include(Catch) diff --git a/src/DrawRender.cpp b/src/DrawRender.cpp index 435a0ec..1d71731 100644 --- a/src/DrawRender.cpp +++ b/src/DrawRender.cpp @@ -1,4 +1,3 @@ -#include "Color.hpp" #include "DrawRender.hpp" #include "vkvm.hpp" #include @@ -28,7 +27,7 @@ void DrawRender::graphicsUpdate(int type) { if(center.x + radius > windowWidth || center.x - radius < 0 || center.y + radius > windowHeight || center.y - radius < 0) { - radius = utils::min(utils::min(center.x, windowWidth - center.x), utils::min(center.y, windowHeight - center.y)); + radius = std::min(std::min(center.x, windowWidth - center.x), std::min(center.y, windowHeight - center.y)); } oldCircle = Circle(center, radius, penWidth, false); diff --git a/src/Rectangle.cpp b/src/Rectangle.cpp index cf5f18b..b136560 100644 --- a/src/Rectangle.cpp +++ b/src/Rectangle.cpp @@ -17,10 +17,10 @@ Rectangle::Rectangle(vkvm::Coordinates mouseLeftDownPostion, vkvm::Coordinates m length = abs(mouseLeftDownPosition.x - mousePosition.x); width = abs(mouseLeftDownPosition.y - mousePosition.y); - uperLeft.x = utils::min(mouseLeftDownPosition.x, mousePosition.x); - uperLeft.y = utils::min(mouseLeftDownPosition.y, mousePosition.y); - bottomRight.x = utils::max(mouseLeftDownPosition.x, mousePosition.x); - bottomRight.y = utils::max(mouseLeftDownPosition.y, mousePosition.y); + uperLeft.x = std::min(mouseLeftDownPosition.x, mousePosition.x); + uperLeft.y = std::min(mouseLeftDownPosition.y, mousePosition.y); + bottomRight.x = std::max(mouseLeftDownPosition.x, mousePosition.x); + bottomRight.y = std::max(mouseLeftDownPosition.y, mousePosition.y); rectangle.resize(width); for(y_draw = 0; y_draw < width; y_draw++) { diff --git a/src/utils.cpp b/src/utils.cpp index 9fb3201..0c63ccb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,7 +1,3 @@ -// -// Created by shaohuatong on 06.12.19. -// - #include "utils.hpp" int utils::squareOfDistance(vkvm::Coordinates x, vkvm::Coordinates y) { @@ -10,16 +6,4 @@ int utils::squareOfDistance(vkvm::Coordinates x, vkvm::Coordinates y) { int utils::getDistance(vkvm::Coordinates x, vkvm::Coordinates y) { return (int)floor(sqrt(squareOfDistance(x, y))); -} - -int utils::min(int x, int y) { - if(x <= y) - return x; - return y; -} - -int utils::max(int x, int y) { - if(x<=y) - return y; - return x; } \ No newline at end of file diff --git a/src/utils.hpp b/src/utils.hpp index c208db5..fd9c082 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -6,15 +6,12 @@ #define SIMPLE_DRAW_UTILS_HPP #include "vkvm.hpp" -#include "internal.hpp" -#include "math.h" +#include class utils { public: static int squareOfDistance(vkvm::Coordinates x, vkvm::Coordinates y); static int getDistance(vkvm::Coordinates x, vkvm::Coordinates y); - static int min(int x, int y); - static int max(int x, int y); };