diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-12-24 22:34:40 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-12-30 14:16:43 +0100 |
commit | 72fde57386eb7b53f4b1a0954a1595e36cf17e5f (patch) | |
tree | 2322902c6976c0e056d12019366444b5b9fcae56 /editeng/qa/unit/EditLineTest.cxx | |
parent | 7de4661827c5bed7beaf2c286242e48cfe4154e8 (diff) |
editeng: EditLine test and refactor constructors, operators
Change-Id: Ia60ce07073725bf66bf299edaf7b3cd24cfe59c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161358
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng/qa/unit/EditLineTest.cxx')
-rw-r--r-- | editeng/qa/unit/EditLineTest.cxx | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/editeng/qa/unit/EditLineTest.cxx b/editeng/qa/unit/EditLineTest.cxx new file mode 100644 index 000000000000..6991ba67755c --- /dev/null +++ b/editeng/qa/unit/EditLineTest.cxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/bootstrapfixture.hxx> +#include <EditLine.hxx> + +namespace +{ +class EditLineTest : public test::BootstrapFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(EditLineTest, testConstruction) +{ + EditLine aNew; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStart()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEnd()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStartPortion()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEndPortion()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aNew.GetMaxAscent()); + CPPUNIT_ASSERT_EQUAL(false, aNew.IsValid()); +} + +CPPUNIT_TEST_FIXTURE(EditLineTest, testCopyConstructor) +{ + EditLine aLine1; + aLine1.SetStart(1); + aLine1.SetEnd(2); + aLine1.SetStartPortion(10); + aLine1.SetEndPortion(20); + aLine1.SetMaxAscent(200); + aLine1.SetValid(); + + // set Line2 + EditLine aLine2(aLine1); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aLine2.GetStart()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aLine2.GetEnd()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aLine2.GetStartPortion()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(20), aLine2.GetEndPortion()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aLine2.GetMaxAscent()); + CPPUNIT_ASSERT_EQUAL(false, aLine2.IsValid()); +} + +CPPUNIT_TEST_FIXTURE(EditLineTest, testAssign) +{ + EditLine aLine1; + aLine1.SetStart(1); + aLine1.SetEnd(2); + aLine1.SetStartPortion(10); + aLine1.SetEndPortion(20); + aLine1.SetMaxAscent(200); + aLine1.SetValid(); + + // set Line2 + EditLine aLine2; + aLine2 = aLine1; + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aLine2.GetStart()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aLine2.GetEnd()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aLine2.GetStartPortion()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(20), aLine2.GetEndPortion()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aLine2.GetMaxAscent()); + CPPUNIT_ASSERT_EQUAL(false, aLine2.IsValid()); +} + +CPPUNIT_TEST_FIXTURE(EditLineTest, testEquals) +{ + EditLine aLine1; + EditLine aLine2; + + // both empty = equal + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); + + aLine1.SetStart(10); + CPPUNIT_ASSERT_EQUAL(false, aLine1 == aLine2); + + aLine2.SetStart(10); + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); + + aLine1.SetEnd(20); + CPPUNIT_ASSERT_EQUAL(false, aLine1 == aLine2); + + aLine2.SetEnd(20); + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); + + aLine1.SetStartPortion(100); + CPPUNIT_ASSERT_EQUAL(false, aLine1 == aLine2); + + aLine2.SetStartPortion(100); + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); + + aLine1.SetEndPortion(200); + CPPUNIT_ASSERT_EQUAL(false, aLine1 == aLine2); + + aLine2.SetEndPortion(200); + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); + + aLine2.SetMaxAscent(200); // doesn't influence equality + CPPUNIT_ASSERT_EQUAL(true, aLine1 == aLine2); +} + +} // end anonymous namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |