From 486f997d257533b889bd5af4c85eb1e2f4c9c152 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 27 Jul 2019 01:47:21 +0900 Subject: unit test for B2DPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I86a9d555e4915658acf5829fbf7c8336255d6343 Reviewed-on: https://gerrit.libreoffice.org/76490 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- basegfx/test/B2DPointTest.cxx | 46 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/basegfx/test/B2DPointTest.cxx b/basegfx/test/B2DPointTest.cxx index 97c5c0714d32..77fa61d90b9d 100644 --- a/basegfx/test/B2DPointTest.cxx +++ b/basegfx/test/B2DPointTest.cxx @@ -19,30 +19,38 @@ #include #include +#include -namespace basegfx -{ -class b2dpoint : public CppUnit::TestFixture +class B2DPointTest : public CppUnit::TestFixture { public: - // insert your test code here. - // this is only demonstration code - void EmptyMethod() - { - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - } - - // Change the following lines only, if you add, remove or rename - // member functions of the current class, - // because these macros are need by auto register mechanism. - - CPPUNIT_TEST_SUITE(b2dpoint); - CPPUNIT_TEST(EmptyMethod); + void testCreation(); + + CPPUNIT_TEST_SUITE(B2DPointTest); + CPPUNIT_TEST(testCreation); CPPUNIT_TEST_SUITE_END(); -}; // class b2dpoint +}; + +void B2DPointTest::testCreation() +{ + basegfx::B2DPoint aPoint1(5.0, 2.0); + CPPUNIT_ASSERT_EQUAL(5.0, aPoint1.getX()); + CPPUNIT_ASSERT_EQUAL(2.0, aPoint1.getY()); + + basegfx::B2DPoint aPoint2 = { 5.0, 2.0 }; + CPPUNIT_ASSERT_EQUAL(5.0, aPoint2.getX()); + CPPUNIT_ASSERT_EQUAL(2.0, aPoint2.getY()); -} // namespace basegfx + std::vector aPointVector{ + { 5.0, 2.0 }, + { 4.0, 3.0 }, + }; + CPPUNIT_ASSERT_EQUAL(5.0, aPointVector[0].getX()); + CPPUNIT_ASSERT_EQUAL(2.0, aPointVector[0].getY()); + CPPUNIT_ASSERT_EQUAL(4.0, aPointVector[1].getX()); + CPPUNIT_ASSERT_EQUAL(3.0, aPointVector[1].getY()); +} -CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b2dpoint); +CPPUNIT_TEST_SUITE_REGISTRATION(B2DPointTest); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3