clean: qtextcodec is going to be deprecated

The convert function is limited compared to iconv
qtextcodec can not cover the common usage of goldendict .
the test can be deleted.
This commit is contained in:
Xiao YiFang 2023-04-16 14:11:32 +08:00 committed by xiaoyifang
parent cd40bfa7d3
commit 59327959a8
2 changed files with 0 additions and 72 deletions

View file

@ -1,23 +0,0 @@
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
CONFIG += qtestlib
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
HEADERS+= \
../iconv.hh \
../wstring.hh \
../wstring_qt.hh
SOURCES += \
test-qtextcodec-convert.cpp \
../iconv.cc \
../wstring_qt.cc
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View file

@ -1,49 +0,0 @@
#include <QTest>
#include <QDate>
#include "../iconv.hh"
#include <string>
#include "../wstring_qt.hh"
//used to test Iconv.cc
class testQTextCodec : public QObject
{
Q_OBJECT
private slots:
void testConvert();
void testToWstring();
void testToUtf8();
};
void testQTextCodec::testConvert()
{
Iconv conv( "utf-8", Iconv::GdWchar );
const char s[] = { 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00 };
void const * in = &s[ 0 ];
size_t len = 12;
QString r = conv.convert( in, len );
QCOMPARE( r, "abc" );
}
void testQTextCodec::testToWstring()
{
const char s[] = { 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63 };
gd::wstring r1 = Iconv::toWstring( "UTF-32BE", s, 12 );
QCOMPARE( r1.size(), 3 );
QCOMPARE( r1, U"abc" );
char32_t * arr = (char32_t*)r1.c_str ();
QCOMPARE( arr[ 0 ], 0x00000061 );
}
void testQTextCodec::testToUtf8()
{
const char s[] = { 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63 };
std::string r1 = Iconv::toUtf8 ( "UTF-32BE", s, 12 );
QCOMPARE( r1.size(), 3 );
QCOMPARE( r1, u8"abc" );
char * arr = (char*)r1.c_str ();
QCOMPARE( arr[ 0 ], 0x61 );
}
QTEST_MAIN(testQTextCodec)
#include "test-qtextcodec-convert.moc"