File indexing completed on 2024-04-28 05:52:32

0001 /*
0002     This file is part of the Okteta Core library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2006, 2011 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "textcharcodectest.hpp"
0010 
0011 // test object
0012 #include <charcodecs/textcharcodec.hpp>
0013 // KF
0014 #include <QTest>
0015 
0016 namespace Okteta {
0017 
0018 //---------------------------------------------------------------------------- Tests -----
0019 
0020 void TextCharCodecTest::testCreateCodec_data()
0021 {
0022     QTest::addColumn<QString>("codecName");
0023 
0024     for (const QString& codecName : TextCharCodec::codecNames()) {
0025         QTest::newRow(codecName.toLatin1().constData()) << codecName;
0026     }
0027 }
0028 
0029 void TextCharCodecTest::testCreateCodec()
0030 {
0031     QFETCH(QString, codecName);
0032 
0033     CharCodec* codec = TextCharCodec::createCodec(codecName);
0034 
0035     QVERIFY(codec != nullptr);
0036     QCOMPARE(codec->name(), codecName);
0037 
0038     delete codec;
0039 }
0040 
0041 void TextCharCodecTest::testCreateLocalCodec()
0042 {
0043     TextCharCodec* codec = TextCharCodec::createLocalCodec();
0044     QVERIFY(codec != nullptr);
0045     delete codec;
0046 }
0047 
0048 void TextCharCodecTest::testCreateNonexistingCodec()
0049 {
0050     TextCharCodec* codec = TextCharCodec::createCodec(QStringLiteral("NonexistingCode"));
0051     QVERIFY(codec == nullptr);
0052 }
0053 
0054 }
0055 
0056 QTEST_GUILESS_MAIN(Okteta::TextCharCodecTest)
0057 
0058 #include "moc_textcharcodectest.cpp"