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