2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2009-11-26 12:22:49 +01:00
|
|
|
|
|
|
|
#include <utils/changeset.h>
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtTest>
|
2009-11-26 12:22:49 +01:00
|
|
|
|
2010-09-02 15:32:04 +10:00
|
|
|
//TESTED_COMPONENT=src/utils/changeset
|
|
|
|
|
2014-05-29 23:12:04 +03:00
|
|
|
using Utils::ChangeSet;
|
|
|
|
|
2009-11-26 12:22:49 +01:00
|
|
|
class tst_ChangeSet : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void singleReplace();
|
|
|
|
void singleMove();
|
|
|
|
void singleInsert();
|
|
|
|
void singleRemove();
|
|
|
|
void singleFlip();
|
|
|
|
void singleCopy();
|
|
|
|
|
|
|
|
void doubleInsert();
|
|
|
|
void conflicts();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleReplace()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.replace(0, 2, "ghi"));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("ghicdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.replace(4, 6, "ghi"));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdghi"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.replace(3, 3, "ghi"));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcghidef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.replace(0, 6, ""));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String(""));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.replace(3, 13, "ghi"));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcghi"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleMove()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.move(0, 2, 4));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("cdabef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(4, 6, 0));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("efabcd"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(3, 13, 0));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("defabc"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(3, 3, 0));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.move(0, 1, 10));
|
|
|
|
cs.apply(&test);
|
|
|
|
// ### maybe this should expand the string or error?
|
|
|
|
QCOMPARE(test, QLatin1String("bcdef"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleInsert()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.insert(0, "ghi"));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("ghiabcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.insert(6, "ghi"));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdefghi"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.insert(3, ""));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.insert(7, "g"));
|
|
|
|
cs.apply(&test);
|
|
|
|
// ### maybe this should expand the string or error?
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleRemove()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.remove(0, 1));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("bcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.remove(3, 6));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abc"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.remove(4, 14));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcd"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.remove(2, 2));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.remove(7, 8));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleFlip()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(0, 2, 3, 6));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
2009-11-26 14:42:19 +01:00
|
|
|
QCOMPARE(test, QLatin1String("defcab"));
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(1, 3, 3, 4));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
2009-11-26 14:42:19 +01:00
|
|
|
QCOMPARE(test, QLatin1String("adbcef"));
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(3, 3, 4, 4));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(3, 3, 4, 5));
|
2009-11-26 14:42:19 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcedf"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 14:42:19 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(0, 6, 6, 12));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(0, 6, 7, 10));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
// ### maybe this should expand the string or error?
|
|
|
|
QCOMPARE(test, QLatin1String(""));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QCOMPARE(cs.flip(0, 3, 1, 4), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QCOMPARE(cs.flip(0, 3, 2, 5), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 14:42:19 +01:00
|
|
|
QVERIFY(cs.flip(0, 3, 0, 0));
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
2009-11-26 14:42:19 +01:00
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 14:42:19 +01:00
|
|
|
QVERIFY(cs.flip(0, 0, 0, 3));
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
2009-11-26 14:42:19 +01:00
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.flip(0, 3, 3, 3));
|
2009-11-26 14:42:19 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::singleCopy()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.copy(0, 2, 4));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdabef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.copy(1, 3, 3));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcbcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.copy(3, 3, 4));
|
2009-11-26 12:22:49 +01:00
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.copy(0, 6, 6));
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcdefabcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
QVERIFY(cs.copy(0, 6, 7));
|
|
|
|
cs.apply(&test);
|
|
|
|
// ### maybe this should expand the string or error?
|
|
|
|
QCOMPARE(test, QLatin1String("abcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QCOMPARE(cs.copy(0, 3, 1), false);
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QCOMPARE(cs.copy(0, 3, 2), false);
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.copy(0, 3, 0));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcabcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.copy(0, 3, 3));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("abcabcdef"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::doubleInsert()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.insert(1, "01"));
|
|
|
|
QVERIFY(cs.insert(1, "234"));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("a01234bcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.insert(1, "234"));
|
|
|
|
QVERIFY(cs.insert(1, "01"));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("a23401bcdef"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.insert(1, "01"));
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.remove(1, 2));
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.insert(2, "234"));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("a01234cdef"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ChangeSet::conflicts()
|
|
|
|
{
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
2009-11-26 12:22:49 +01:00
|
|
|
QCOMPARE(cs.replace(0, 2, "abc"), false);
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(1, 4, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(1, 2, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(2, 2, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(2, 3, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(3, 3, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(3, 4, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QCOMPARE(cs.replace(4, 6, "abc"), false);
|
2009-11-26 12:22:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
2009-11-26 12:22:49 +01:00
|
|
|
QVERIFY(cs.replace(0, 1, "bla"));
|
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("blaebcdf"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QVERIFY(cs.replace(4, 5, "bla"));
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("ablabcdf"));
|
|
|
|
}
|
|
|
|
{
|
2014-05-29 23:12:04 +03:00
|
|
|
ChangeSet cs;
|
2010-06-29 10:54:21 +02:00
|
|
|
QVERIFY(cs.move(1, 4, 5));
|
|
|
|
QVERIFY(cs.replace(5, 6, "bla"));
|
2009-11-26 12:22:49 +01:00
|
|
|
QString test("abcdef");
|
|
|
|
cs.apply(&test);
|
|
|
|
QCOMPARE(test, QLatin1String("aebcdbla"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-10 12:21:30 +02:00
|
|
|
QTEST_GUILESS_MAIN(tst_ChangeSet)
|
2009-11-26 12:22:49 +01:00
|
|
|
|
|
|
|
#include "tst_changeset.moc"
|