2018-03-11 19:20:36 +01:00
|
|
|
/***********************************************************************
|
2018-10-03 22:23:55 +02:00
|
|
|
* fpoint-test.cpp - FPoint unit tests *
|
2018-03-11 19:20:36 +01:00
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* This file is part of the FINAL CUT widget toolkit *
|
2018-03-11 19:20:36 +01:00
|
|
|
* *
|
2020-04-19 20:38:52 +02:00
|
|
|
* Copyright 2018-2020 Markus Gans *
|
2018-03-11 19:20:36 +01:00
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
2018-03-11 19:20:36 +01:00
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* FINAL CUT is distributed in the hope that it will be useful, but *
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
2018-03-11 19:20:36 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
|
|
|
|
2018-11-21 22:15:14 +01:00
|
|
|
#include <limits>
|
2019-08-06 23:45:28 +02:00
|
|
|
#include <utility>
|
2018-11-21 22:15:14 +01:00
|
|
|
|
2018-03-11 19:20:36 +01:00
|
|
|
#include <cppunit/BriefTestProgressListener.h>
|
|
|
|
#include <cppunit/CompilerOutputter.h>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include <cppunit/TestFixture.h>
|
|
|
|
#include <cppunit/TestResult.h>
|
|
|
|
#include <cppunit/TestResultCollector.h>
|
|
|
|
#include <cppunit/TestRunner.h>
|
|
|
|
|
|
|
|
#include <final/final.h>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FPointTest
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FPointTest : public CPPUNIT_NS::TestFixture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FPointTest()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
2018-03-13 01:04:46 +01:00
|
|
|
void classNameTest();
|
2018-03-18 15:03:07 +01:00
|
|
|
void noArgumentTest();
|
2018-03-11 19:20:36 +01:00
|
|
|
void copyConstructorTest();
|
2019-07-31 23:57:35 +02:00
|
|
|
void moveConstructorTest();
|
2018-03-11 19:20:36 +01:00
|
|
|
void assignmentTest();
|
|
|
|
void additionAssignmentTest();
|
|
|
|
void subtractionAssignmentTest();
|
|
|
|
void equalTest();
|
|
|
|
void notEqualTest();
|
|
|
|
void additionTest();
|
|
|
|
void subtractionTest();
|
|
|
|
void referenceTest();
|
2019-12-16 11:14:24 +01:00
|
|
|
void moveTest();
|
2018-04-16 02:24:37 +02:00
|
|
|
void streamInsertionTest();
|
|
|
|
void streamExtractionTest();
|
2018-03-11 19:20:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Adds code needed to register the test suite
|
|
|
|
CPPUNIT_TEST_SUITE (FPointTest);
|
|
|
|
|
|
|
|
// Add a methods to the test suite
|
2018-03-13 01:04:46 +01:00
|
|
|
CPPUNIT_TEST (classNameTest);
|
2018-03-18 15:03:07 +01:00
|
|
|
CPPUNIT_TEST (noArgumentTest);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_TEST (copyConstructorTest);
|
2019-07-31 23:57:35 +02:00
|
|
|
CPPUNIT_TEST (moveConstructorTest);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_TEST (assignmentTest);
|
|
|
|
CPPUNIT_TEST (additionAssignmentTest);
|
|
|
|
CPPUNIT_TEST (subtractionAssignmentTest);
|
|
|
|
CPPUNIT_TEST (equalTest);
|
|
|
|
CPPUNIT_TEST (notEqualTest);
|
|
|
|
CPPUNIT_TEST (additionTest);
|
|
|
|
CPPUNIT_TEST (subtractionTest);
|
|
|
|
CPPUNIT_TEST (referenceTest);
|
2019-12-16 11:14:24 +01:00
|
|
|
CPPUNIT_TEST (moveTest);
|
2018-04-16 02:24:37 +02:00
|
|
|
CPPUNIT_TEST (streamInsertionTest);
|
|
|
|
CPPUNIT_TEST (streamExtractionTest);
|
2018-03-11 19:20:36 +01:00
|
|
|
|
|
|
|
// End of test suite definition
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
2019-09-08 02:04:24 +02:00
|
|
|
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2018-03-13 01:04:46 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::classNameTest()
|
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FPoint p;
|
2019-10-05 23:20:07 +02:00
|
|
|
const finalcut::FString& classname = p.getClassName();
|
|
|
|
CPPUNIT_ASSERT ( classname == "FPoint" );
|
2018-03-13 01:04:46 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 19:20:36 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-03-18 15:03:07 +01:00
|
|
|
void FPointTest::noArgumentTest()
|
2018-03-11 19:20:36 +01:00
|
|
|
{
|
2018-12-10 01:48:26 +01:00
|
|
|
const finalcut::FPoint point{};
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( point.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( point.getY() == 0 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( point.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::copyConstructorTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (15, 10);
|
2018-09-20 23:59:01 +02:00
|
|
|
const finalcut::FPoint p2 (p1);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 15 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 10 );
|
|
|
|
}
|
|
|
|
|
2019-07-31 23:57:35 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::moveConstructorTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
finalcut::FPoint p1 (25, 16);
|
2019-07-31 23:57:35 +02:00
|
|
|
const finalcut::FPoint p2 (std::move(p1));
|
2020-04-19 20:38:52 +02:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 25 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 16 );
|
2019-07-31 23:57:35 +02:00
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 25 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 16 );
|
|
|
|
}
|
|
|
|
|
2018-03-11 19:20:36 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::assignmentTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (-99, 100);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == -99 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 100 );
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FPoint p2;
|
2018-03-11 19:20:36 +01:00
|
|
|
p2 = p1;
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == -99 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 100 );
|
|
|
|
|
|
|
|
p2 = -p1;
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 99 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == -100 );
|
|
|
|
|
|
|
|
p2.setPoint (80, 24);
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 80 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 24 );
|
|
|
|
|
|
|
|
p2.setX(40);
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 40 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 24 );
|
|
|
|
|
|
|
|
p2.setY(12);
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 40 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 12 );
|
|
|
|
|
2019-07-31 23:57:35 +02:00
|
|
|
// Move assignment operator
|
|
|
|
finalcut::FPoint p3 = std::move(p2);
|
2020-04-19 20:38:52 +02:00
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 40 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 12 );
|
|
|
|
CPPUNIT_ASSERT ( ! p2.isOrigin() );
|
2019-07-31 23:57:35 +02:00
|
|
|
CPPUNIT_ASSERT ( p3.getX() == 40 );
|
|
|
|
CPPUNIT_ASSERT ( p3.getY() == 12 );
|
|
|
|
|
2018-11-21 22:15:14 +01:00
|
|
|
// Value limit
|
2019-07-31 23:57:35 +02:00
|
|
|
const finalcut::FPoint p4 ( std::numeric_limits<int>::min()
|
2018-11-21 22:15:14 +01:00
|
|
|
, std::numeric_limits<int>::max() );
|
2019-07-31 23:57:35 +02:00
|
|
|
CPPUNIT_ASSERT ( p4.getX() == std::numeric_limits<int>::min() );
|
|
|
|
CPPUNIT_ASSERT ( p4.getY() == std::numeric_limits<int>::max() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::additionAssignmentTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
finalcut::FPoint p1 (1, 2);
|
|
|
|
p1 += finalcut::FPoint (3, 1);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 4 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 3 );
|
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 += finalcut::FPoint (-4, -3);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2018-11-21 22:15:14 +01:00
|
|
|
// Value limit
|
|
|
|
finalcut::FPoint p2 ( std::numeric_limits<int>::max()
|
|
|
|
, std::numeric_limits<int>::min() );
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == std::numeric_limits<int>::max() );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min() );
|
|
|
|
p2 += finalcut::FPoint ( -std::numeric_limits<int>::max()
|
2019-01-16 16:00:15 +01:00
|
|
|
, std::numeric_limits<int>::max() );
|
2018-11-21 22:15:14 +01:00
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 0 );
|
2019-01-21 03:42:18 +01:00
|
|
|
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min()
|
|
|
|
+ std::numeric_limits<int>::max() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::subtractionAssignmentTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
finalcut::FPoint p1 (10, 20);
|
|
|
|
p1 -= finalcut::FPoint (5, 5);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 5 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 15 );
|
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= finalcut::FPoint (-5, 20);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 10 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == -5 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( ! p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= finalcut::FPoint (-10, 0);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 20 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == -5 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( ! p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= finalcut::FPoint (20, 0);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == -5 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( ! p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= finalcut::FPoint (0, -6);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 1 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( ! p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= finalcut::FPoint (1, 0);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == -1 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 1 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( ! p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2019-08-06 23:45:28 +02:00
|
|
|
p1 -= (finalcut::FPoint (0, 1) + finalcut::FPoint (-1, 0));
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
2019-01-16 16:00:15 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.isOrigin() );
|
2018-03-11 19:20:36 +01:00
|
|
|
|
2018-11-21 22:15:14 +01:00
|
|
|
// Value limit
|
|
|
|
finalcut::FPoint p2 ( std::numeric_limits<int>::max()
|
|
|
|
, std::numeric_limits<int>::min() );
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == std::numeric_limits<int>::max() );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min() );
|
|
|
|
p2 -= finalcut::FPoint ( std::numeric_limits<int>::max(),
|
|
|
|
std::numeric_limits<int>::min() );
|
|
|
|
CPPUNIT_ASSERT ( p2.getX() == 0 );
|
|
|
|
CPPUNIT_ASSERT ( p2.getY() == 0 );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::equalTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (1, 2);
|
|
|
|
const finalcut::FPoint p2 (1, 2);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1 == p2 );
|
2019-08-06 23:45:28 +02:00
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint(1, 2) == p2 );
|
|
|
|
CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1, 2) );
|
2018-12-10 01:48:26 +01:00
|
|
|
const finalcut::FPoint p3{};
|
|
|
|
const finalcut::FPoint p4{};
|
2018-10-22 01:26:24 +02:00
|
|
|
CPPUNIT_ASSERT ( p3 == p4 );
|
|
|
|
CPPUNIT_ASSERT ( p3 == -p4 );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::notEqualTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (1, 2);
|
|
|
|
const finalcut::FPoint p2 (2, 4);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1 != p2 );
|
2019-08-06 23:45:28 +02:00
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint(1, 2) != p2 );
|
|
|
|
CPPUNIT_ASSERT ( p1 != finalcut::FPoint(2, 4) );
|
2018-09-20 23:59:01 +02:00
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint() != p2 );
|
|
|
|
CPPUNIT_ASSERT ( p1 != finalcut::FPoint() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::additionTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (1, 2);
|
|
|
|
const finalcut::FPoint p2 (5, 8);
|
2018-09-20 23:59:01 +02:00
|
|
|
const finalcut::FPoint p3 = p1 + p2;
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p3.getX() == 6 );
|
|
|
|
CPPUNIT_ASSERT ( p3.getY() == 10 );
|
2019-08-06 23:45:28 +02:00
|
|
|
CPPUNIT_ASSERT ( p1 + p2 == finalcut::FPoint(6, 10) );
|
2018-09-20 23:59:01 +02:00
|
|
|
CPPUNIT_ASSERT ( p1 + finalcut::FPoint() == p1 );
|
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint() + p2 == p2 );
|
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint() + finalcut::FPoint() == finalcut::FPoint() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::subtractionTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
const finalcut::FPoint p1 (-5, -20);
|
|
|
|
const finalcut::FPoint p2 (0, -30);
|
2018-09-20 23:59:01 +02:00
|
|
|
const finalcut::FPoint p3 = p1 - p2;
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p3.getX() == -5 );
|
|
|
|
CPPUNIT_ASSERT ( p3.getY() == 10 );
|
2019-08-06 23:45:28 +02:00
|
|
|
CPPUNIT_ASSERT ( p1 - p2 == finalcut::FPoint(-5, 10) );
|
2018-09-20 23:59:01 +02:00
|
|
|
CPPUNIT_ASSERT ( p1 - finalcut::FPoint() == p1 );
|
|
|
|
CPPUNIT_ASSERT ( finalcut::FPoint() - finalcut::FPoint() == finalcut::FPoint() );
|
2018-03-11 19:20:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::referenceTest()
|
|
|
|
{
|
2019-08-06 23:45:28 +02:00
|
|
|
finalcut::FPoint p1 (1, 1);
|
2018-03-11 19:20:36 +01:00
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 1 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 1 );
|
|
|
|
|
|
|
|
p1.x_ref()++;
|
|
|
|
p1.y_ref()++;
|
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 2 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 2 );
|
|
|
|
|
2018-11-21 22:15:14 +01:00
|
|
|
int& x = p1.x_ref();
|
|
|
|
int& y = p1.y_ref();
|
2018-03-11 19:20:36 +01:00
|
|
|
x += 4;
|
|
|
|
y += 2;
|
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 6 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 4 );
|
|
|
|
}
|
|
|
|
|
2019-12-16 11:14:24 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::moveTest()
|
|
|
|
{
|
|
|
|
finalcut::FPoint p1 (4, 3);
|
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 4 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 3 );
|
|
|
|
|
|
|
|
const finalcut::FPoint p2 (2, 3);
|
|
|
|
p1.move(p2);
|
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 6 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == 6 );
|
|
|
|
|
|
|
|
p1.move (-2, -7);
|
|
|
|
CPPUNIT_ASSERT ( p1.getX() == 4 );
|
|
|
|
CPPUNIT_ASSERT ( p1.getY() == -1 );
|
|
|
|
}
|
|
|
|
|
2018-04-16 02:24:37 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::streamInsertionTest()
|
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FPoint out;
|
2018-04-16 02:24:37 +02:00
|
|
|
std::stringstream stream;
|
|
|
|
stream.str("10 5");
|
|
|
|
stream >> out;
|
|
|
|
CPPUNIT_ASSERT ( out.getX() == 10 );
|
|
|
|
CPPUNIT_ASSERT ( out.getY() == 5 );
|
|
|
|
|
|
|
|
stream.clear();
|
|
|
|
stream.str("-3 -9");
|
|
|
|
stream >> out;
|
|
|
|
CPPUNIT_ASSERT ( out.getX() == -3 );
|
|
|
|
CPPUNIT_ASSERT ( out.getY() == -9 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FPointTest::streamExtractionTest()
|
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FPoint in;
|
2018-04-16 02:24:37 +02:00
|
|
|
in.setPoint (-7, 5);
|
|
|
|
std::stringstream stream;
|
|
|
|
stream << in;
|
|
|
|
CPPUNIT_ASSERT ( stream.str() == "-7 5" );
|
|
|
|
|
|
|
|
in.setPoint (127, 150);
|
|
|
|
stream.clear();
|
|
|
|
stream.str("");
|
|
|
|
stream << in;
|
|
|
|
CPPUNIT_ASSERT ( stream.str() == "127 150" );
|
|
|
|
}
|
|
|
|
|
2018-03-11 19:20:36 +01:00
|
|
|
// Put the test suite in the registry
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION (FPointTest);
|
|
|
|
|
|
|
|
// The general unit test main part
|
|
|
|
#include <main-test.inc>
|