Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/editeng/qa/unit/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 6 kB image not shown  

Quellcode-Bibliothek EditLineListTest.cxx

  Sprache: C
 

/* -*- 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 <EditLineList.hxx>

namespace
{
class EditLineListTest : public test::BootstrapFixture
{
};

CPPUNIT_TEST_FIXTURE(EditLineListTest, testConstruction)
{
    EditLineList aNewList;
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.Count());
}

CPPUNIT_TEST_FIXTURE(EditLineListTest, testAppendAndInsert)
{
    // Test case:
    // Append EditLine1
    // Append EditLine3
    // Insert EditLine2 in-between EditLine1 and pEditLine3

    EditLineList aNewList;

    EditLine* pEditLine1 = new EditLine;
    EditLine* pEditLine2 = new EditLine;
    EditLine* pEditLine3 = new EditLine;

    aNewList.Append(std::unique_ptr<EditLine>(pEditLine1));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.Count());

    aNewList.Append(std::unique_ptr<EditLine>(pEditLine3));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.Count());

    CPPUNIT_ASSERT_EQUAL(pEditLine1, &aNewList[0]);
    CPPUNIT_ASSERT_EQUAL(pEditLine3, &aNewList[1]);

    aNewList.Insert(1, std::unique_ptr<EditLine>(pEditLine2));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aNewList.Count());

    CPPUNIT_ASSERT_EQUAL(pEditLine1, &aNewList[0]);
    CPPUNIT_ASSERT_EQUAL(pEditLine2, &aNewList[1]);
    CPPUNIT_ASSERT_EQUAL(pEditLine3, &aNewList[2]);
}

CPPUNIT_TEST_FIXTURE(EditLineListTest, testReset)
{
    EditLineList aNewList;

    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());

    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aNewList.Count());

    aNewList.Reset();

    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.Count());
}

CPPUNIT_TEST_FIXTURE(EditLineListTest, testDeleteFrom)
{
    EditLineList aNewList;

    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());

    aNewList[0].SetStart(10);
    aNewList[1].SetStart(11);
    aNewList[2].SetStart(12);
    aNewList[3].SetStart(13);
    aNewList[4].SetStart(14);

    CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aNewList.Count());

    aNewList.DeleteFromLine(2);

    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.Count());

    CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());

    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());
    aNewList.Append(std::make_unique<EditLine>());

    aNewList[2].SetStart(15);
    aNewList[3].SetStart(16);
    aNewList[4].SetStart(17);
    aNewList[5].SetStart(18);

    CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aNewList.Count());

    CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(15), aNewList[2].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aNewList[3].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(17), aNewList[4].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(18), aNewList[5].GetStart());

    aNewList.DeleteFromLine(4);

    CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aNewList.Count());

    CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(15), aNewList[2].GetStart());
    CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aNewList[3].GetStart());
}

CPPUNIT_TEST_FIXTURE(EditLineListTest, testFindLine)
{
    EditLineList aNewList;
    EditLine* pEditLine1 = new EditLine;
    pEditLine1->SetStart(0);
    pEditLine1->SetEnd(10);
    aNewList.Append(std::unique_ptr<EditLine>(pEditLine1));

    EditLine* pEditLine2 = new EditLine;
    pEditLine2->SetStart(10);
    pEditLine2->SetEnd(20);
    aNewList.Append(std::unique_ptr<EditLine>(pEditLine2));

    EditLine* pEditLine3 = new EditLine;
    pEditLine3->SetStart(20);
    pEditLine3->SetEnd(30);
    aNewList.Append(std::unique_ptr<EditLine>(pEditLine3));

    // Exclude end
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(-1false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(0false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(5false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(9false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(10false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(15false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(19false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(20false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(25false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(30false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(31false));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(10000false));

    // Include end
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(-1true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(0true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(5true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(9true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.FindLine(10true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(15true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(19true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.FindLine(20true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(25true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(30true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(31true));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.FindLine(10000true));
}

// end anonymous namespace

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5 in Prozent
C=91 H=99 G=94

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:  (vorverarbeitet am  2026-06-06) ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.