1#include <QtTest/QTest>
2
3#include <poppler-private.h>
4
5#include "PageLabelInfo_p.h"
6
7#include "config.h"
8
9class TestPageLabelInfo : public QObject
10{
11 Q_OBJECT
12public:
13 explicit TestPageLabelInfo(QObject *parent = nullptr) : QObject(parent) { }
14private slots:
15 void testFromDecimal();
16 void testFromDecimalUnicode();
17 void testToRoman();
18 void testFromRoman();
19 void testToLatin();
20 void testFromLatin();
21};
22
23void TestPageLabelInfo::testFromDecimal()
24{
25 std::string str { "2342" };
26 const auto res = fromDecimal(str, unicode: false);
27 QCOMPARE(res.first, 2342);
28 QCOMPARE(res.second, true);
29}
30
31void TestPageLabelInfo::testFromDecimalUnicode()
32{
33 std::unique_ptr<GooString> str(Poppler::QStringToUnicodeGooString(s: QString::fromLocal8Bit(ba: "2342")));
34 const auto res = fromDecimal(str: str->toStr(), unicode: hasUnicodeByteOrderMark(s: str->toStr()));
35 QCOMPARE(res.first, 2342);
36 QCOMPARE(res.second, true);
37}
38
39void TestPageLabelInfo::testToRoman()
40{
41 GooString str;
42 toRoman(number: 177, str: &str, uppercase: false);
43 QCOMPARE(str.c_str(), "clxxvii");
44}
45
46void TestPageLabelInfo::testFromRoman()
47{
48 GooString roman("clxxvii");
49 QCOMPARE(fromRoman(roman.c_str()), 177);
50}
51
52void TestPageLabelInfo::testToLatin()
53{
54 GooString str;
55 toLatin(number: 54, str: &str, uppercase: false);
56 QCOMPARE(str.c_str(), "bbb");
57}
58
59void TestPageLabelInfo::testFromLatin()
60{
61 GooString latin("ddd");
62 QCOMPARE(fromLatin(latin.c_str()), 56);
63}
64
65QTEST_GUILESS_MAIN(TestPageLabelInfo)
66#include "check_pagelabelinfo.moc"
67

source code of poppler/qt6/tests/check_pagelabelinfo.cpp