summaryrefslogtreecommitdiff
path: root/editeng/qa/unit/EditLineTest.cxx
blob: 6991ba67755cefee1a9f1265b2034e79db877187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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: */