diff --git a/dgl/Geometry.hpp b/dgl/Geometry.hpp index f7fe31ec..e922d683 100644 --- a/dgl/Geometry.hpp +++ b/dgl/Geometry.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2021 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -21,7 +21,7 @@ START_NAMESPACE_DGL -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // Forward class names template class Line; @@ -29,7 +29,7 @@ template class Circle; template class Triangle; template class Rectangle; -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- /** DGL Point class. @@ -121,7 +121,7 @@ private: template friend class Rectangle; }; -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- /** DGL Size class. @@ -346,10 +346,12 @@ public: */ void moveBy(const Point& pos) noexcept; +#ifndef DPF_TEST_POINT_CPP /** Draw this line using the current OpenGL state. */ void draw(); +#endif /** Return true if line is null (start and end pos are equal). @@ -460,6 +462,7 @@ public: */ void setNumSegments(const uint num); +#ifndef DPF_TEST_POINT_CPP /** Draw this circle using the current OpenGL state. */ @@ -469,6 +472,7 @@ public: Draw lines (outline of this circle) using the current OpenGL state. */ void drawOutline(); +#endif Circle& operator=(const Circle& cir) noexcept; bool operator==(const Circle& cir) const noexcept; @@ -540,6 +544,7 @@ public: */ bool isInvalid() const noexcept; +#ifndef DPF_TEST_POINT_CPP /** Draw this triangle using the current OpenGL state. */ @@ -549,6 +554,7 @@ public: Draw lines (outline of this triangle) using the current OpenGL state. */ void drawOutline(); +#endif Triangle& operator=(const Triangle& tri) noexcept; bool operator==(const Triangle& tri) const noexcept; @@ -557,8 +563,10 @@ public: private: Point fPos1, fPos2, fPos3; +#ifndef DPF_TEST_POINT_CPP /** @internal */ void _draw(const bool outline); +#endif }; // ----------------------------------------------------------------------- @@ -722,6 +730,7 @@ public: */ bool containsY(const T& y) const noexcept; +#ifndef DPF_TEST_POINT_CPP /** Draw this rectangle using the current OpenGL state. */ @@ -731,6 +740,7 @@ public: Draw lines (outline of this rectangle) using the current OpenGL state. */ void drawOutline(); +#endif Rectangle& operator=(const Rectangle& rect) noexcept; Rectangle& operator*=(double m) noexcept; @@ -742,8 +752,10 @@ private: Point fPos; Size fSize; +#ifndef DPF_TEST_POINT_CPP /** @internal */ void _draw(const bool outline); +#endif }; // ----------------------------------------------------------------------- diff --git a/dgl/src/Geometry.cpp b/dgl/src/Geometry.cpp index d133985f..01af9620 100644 --- a/dgl/src/Geometry.cpp +++ b/dgl/src/Geometry.cpp @@ -599,6 +599,7 @@ void Circle::setNumSegments(const uint num) fSin = std::sin(fTheta); } +#ifndef DPF_TEST_POINT_CPP template void Circle::draw() { @@ -610,6 +611,7 @@ void Circle::drawOutline() { _draw(true); } +#endif template Circle& Circle::operator=(const Circle& cir) noexcept @@ -686,6 +688,7 @@ bool Triangle::isInvalid() const noexcept return fPos1 == fPos2 || fPos1 == fPos3; } +#ifndef DPF_TEST_POINT_CPP template void Triangle::draw() { @@ -697,6 +700,7 @@ void Triangle::drawOutline() { _draw(true); } +#endif template Triangle& Triangle::operator=(const Triangle& tri) noexcept @@ -900,6 +904,7 @@ bool Rectangle::containsY(const T& y) const noexcept return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); } +#ifndef DPF_TEST_POINT_CPP template void Rectangle::draw() { @@ -911,6 +916,7 @@ void Rectangle::drawOutline() { _draw(true); } +#endif template Rectangle& Rectangle::operator=(const Rectangle& rect) noexcept diff --git a/tests/Makefile b/tests/Makefile index e9eea49f..e3b88087 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -20,7 +20,7 @@ BUILD_CXX_FLAGS += -Wno-missing-field-initializers -Wno-extra # --------------------------------------------------------------------------------------------------------------------- -TESTS = Application Color +TESTS = Application Color Point TARGETS = $(TESTS:%=../build/tests/%) OBJS = $(TARGETS:%=%.cpp.o) diff --git a/tests/Point.cpp b/tests/Point.cpp index 578688c6..742ba29c 100644 --- a/tests/Point.cpp +++ b/tests/Point.cpp @@ -14,12 +14,32 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "tests.hpp" + +#define DPF_TEST_POINT_CPP +#include "dgl/src/Geometry.cpp" + // -------------------------------------------------------------------------------------------------------------------- int main() { USE_NAMESPACE_DGL; + // basic usage + { + Point p; + DISTRHO_ASSERT_EQUAL(p.getX(), 0, "point start X value is 0"); + DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value is 0"); + + p.setX(5); + DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value changed to 5"); + DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value remains 0"); + + p.setY(7); + DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value remains 5"); + DISTRHO_ASSERT_EQUAL(p.getY(), 7, "point Y value changed to 7"); + } + // TODO return 0;