diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-02 13:06:58 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:07 -0300 |
commit | 6bb2780c978d93b6ebe7b423adda27e4292467f2 (patch) | |
tree | 975bb03485f15e28e514a5333fdced6f8a2c246f /tests/libsample | |
parent | f3b6eeccd43fc8b81bb7fe48424b6f4c6e4e454d (diff) |
Added test for removed pointer out argument.
Diffstat (limited to 'tests/libsample')
-rw-r--r-- | tests/libsample/point.cpp | 9 | ||||
-rw-r--r-- | tests/libsample/point.h | 6 | ||||
-rw-r--r-- | tests/libsample/pointf.cpp | 9 | ||||
-rw-r--r-- | tests/libsample/pointf.h | 8 |
4 files changed, 29 insertions, 3 deletions
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 @@ -34,6 +34,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() { cout << "(x: " << m_x << ", y: " << m_y << ")"; 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 - |