summaryrefslogtreecommitdiff
path: root/qt5/tests/check_pagelabelinfo.cpp
blob: a8e0f9efbfa05ee8294732cb02dc6d3c01beb6e5 (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
#include <QtTest/QtTest>

#include <poppler-private.h>

#include "PageLabelInfo_p.h"

#include "config.h"

class TestPageLabelInfo : public QObject
{
    Q_OBJECT
public:
    explicit TestPageLabelInfo(QObject *parent = nullptr) : QObject(parent) { }
private slots:
    void testFromDecimal();
    void testFromDecimalUnicode();
    void testToRoman();
    void testFromRoman();
    void testToLatin();
    void testFromLatin();
};

void TestPageLabelInfo::testFromDecimal()
{
    std::string str { "2342" };
    const auto res = fromDecimal(str, false);
    QCOMPARE(res.first, 2342);
    QCOMPARE(res.second, true);
}

void TestPageLabelInfo::testFromDecimalUnicode()
{
    std::unique_ptr<GooString> str(Poppler::QStringToUnicodeGooString(QString::fromLocal8Bit("2342")));
    const auto res = fromDecimal(str->toStr(), str->hasUnicodeMarker());
    QCOMPARE(res.first, 2342);
    QCOMPARE(res.second, true);
}

void TestPageLabelInfo::testToRoman()
{
    GooString str;
    toRoman(177, &str, false);
    QCOMPARE(str.c_str(), "clxxvii");
}

void TestPageLabelInfo::testFromRoman()
{
    GooString roman("clxxvii");
    QCOMPARE(fromRoman(roman.c_str()), 177);
}

void TestPageLabelInfo::testToLatin()
{
    GooString str;
    toLatin(54, &str, false);
    QCOMPARE(str.c_str(), "bbb");
}

void TestPageLabelInfo::testFromLatin()
{
    GooString latin("ddd");
    QCOMPARE(fromLatin(latin.c_str()), 56);
}

QTEST_GUILESS_MAIN(TestPageLabelInfo)
#include "check_pagelabelinfo.moc"