From 6bb2780c978d93b6ebe7b423adda27e4292467f2 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Tue, 2 Aug 2011 13:06:58 -0300 Subject: Added test for removed pointer out argument. --- tests/libsample/point.cpp | 9 +++++++++ tests/libsample/point.h | 6 +++++- tests/libsample/pointf.cpp | 9 +++++++++ tests/libsample/pointf.h | 8 ++++++-- 4 files changed, 29 insertions(+), 3 deletions(-) (limited to 'tests/libsample') diff --git a/tests/libsample/point.cpp b/tests/libsample/point.cpp index 484e7c11c..61e2830e4 100644 --- a/tests/libsample/point.cpp +++ b/tests/libsample/point.cpp @@ -33,6 +33,15 @@ Point::Point(double x, double y) : m_x(x), m_y(y) { } +void +Point::midpoint(const Point& other, Point* midpoint) const +{ + if (!midpoint) + return; + midpoint->setX((m_x + other.m_x) / 2.0); + midpoint->setY((m_y + other.m_y) / 2.0); +} + Point* Point::copy() const { diff --git a/tests/libsample/point.h b/tests/libsample/point.h index cc7a1bc5a..45b1edd39 100644 --- a/tests/libsample/point.h +++ b/tests/libsample/point.h @@ -43,6 +43,11 @@ public: inline void setXAsUint(unsigned int x) { m_x = x; } inline void setYAsUint(unsigned int y) { m_y = y; } + // This method could simply return the midpoint, + // but the interesting part of the test is to set the + // result in the pointer argument. + void midpoint(const Point& other, Point* midpoint) const; + Point* copy() const; inline const Point& getConstReferenceToSelf() const { return *this; } @@ -86,4 +91,3 @@ LIBSAMPLE_API Point transmuteComplexIntoPoint(const Complex& cpx); LIBSAMPLE_API Point operator*(const Point& pt, double multiplier); #endif // POINT_H - diff --git a/tests/libsample/pointf.cpp b/tests/libsample/pointf.cpp index 2464c22bb..509863c41 100644 --- a/tests/libsample/pointf.cpp +++ b/tests/libsample/pointf.cpp @@ -33,6 +33,15 @@ PointF::PointF(double x, double y) : m_x(x), m_y(y) { } +void +PointF::midpoint(const PointF& other, PointF* midpoint) const +{ + if (!midpoint) + return; + midpoint->setX((m_x + other.m_x) / 2.0); + midpoint->setY((m_y + other.m_y) / 2.0); +} + void PointF::show() { diff --git a/tests/libsample/pointf.h b/tests/libsample/pointf.h index 832c3b323..f5ad11659 100644 --- a/tests/libsample/pointf.h +++ b/tests/libsample/pointf.h @@ -41,8 +41,13 @@ public: inline void setX(double x) { m_x = x; } inline void setY(double y) { m_y = y; } + // This method could simply return the midpoint, + // but the interesting part of the test is to set the + // result in the pointer argument. + void midpoint(const PointF& other, PointF* midpoint) const; + // The != operator is not implemented for the purpose of testing - // for the absense of the __ne__ method in the Python binding. + // for the absence of the __ne__ method in the Python binding. bool operator==(const PointF& other); PointF operator+(const PointF& other); @@ -75,4 +80,3 @@ LIBSAMPLE_API bool operator!(const PointF& pt); LIBSAMPLE_API PointF operator*(const PointF& pt, double multiplier); #endif // POINTF_H - -- cgit v1.2.3