File indexing completed on 2024-11-24 05:00:37
0001 /* 0002 SPDX-FileCopyrightText: 2011 Andriy Rysin <rysin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <QTest> 0008 0009 #include "../iso_codes.h" 0010 0011 class IsoCodesTest : public QObject 0012 { 0013 Q_OBJECT 0014 0015 IsoCodes *isoCodes; 0016 0017 private Q_SLOTS: 0018 void initTestCase() 0019 { 0020 // isoCodes = new IsoCodes(IsoCodes::iso_639); 0021 isoCodes = new IsoCodes(IsoCodes::iso_639_3); 0022 } 0023 0024 void cleanupTestCase() 0025 { 0026 delete isoCodes; 0027 } 0028 0029 void testIsoCodes() 0030 { 0031 QVERIFY(isoCodes != nullptr); 0032 QVERIFY(!isoCodes->getEntryList().isEmpty()); 0033 // const IsoCodeEntry* isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_2T_code, "eng"); 0034 const IsoCodeEntry *isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_3_id, QStringLiteral("eng")); 0035 QVERIFY(isoEntry != nullptr); 0036 QVERIFY(!isoEntry->empty()); 0037 // QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_2T_code), QString("eng") ); 0038 // QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_2B_code), QString("eng") ); 0039 // QCOMPARE( isoEntry->value(IsoCodes::attr_iso_639_1_code), QString("en") ); 0040 QCOMPARE(isoEntry->value("name"), QString("English")); 0041 // QCOMPARE( isoEntry->value("status"), QString("Active") ); 0042 } 0043 0044 void testIso639_3_Codes() 0045 { 0046 QVERIFY(isoCodes != nullptr); 0047 QVERIFY(!isoCodes->getEntryList().isEmpty()); 0048 const IsoCodeEntry *isoEntry = isoCodes->getEntry(IsoCodes::attr_iso_639_3_id, QStringLiteral("ant")); 0049 QVERIFY(isoEntry != nullptr); 0050 QVERIFY(!isoEntry->empty()); 0051 QVERIFY(isoEntry->value("name") != QString("ant")); 0052 QCOMPARE(isoEntry->value("name"), QString("Antakarinya")); 0053 } 0054 0055 void loadIsoCodesBenchmark() 0056 { 0057 QBENCHMARK { 0058 IsoCodes *isoCodes = new IsoCodes(IsoCodes::iso_639_3); 0059 delete isoCodes; 0060 } 0061 } 0062 }; 0063 0064 QTEST_MAIN(IsoCodesTest) 0065 0066 #include "iso_codes_test.moc"