From 59327959a81aab1253cd64f363dfd2b43f83c234 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 16 Apr 2023 14:11:32 +0800 Subject: [PATCH] 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. --- autotests/goldendict-test.pro | 23 ------------- autotests/test-qtextcodec-convert.cpp | 49 --------------------------- 2 files changed, 72 deletions(-) delete mode 100644 autotests/goldendict-test.pro delete mode 100644 autotests/test-qtextcodec-convert.cpp diff --git a/autotests/goldendict-test.pro b/autotests/goldendict-test.pro deleted file mode 100644 index 82570c14..00000000 --- a/autotests/goldendict-test.pro +++ /dev/null @@ -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 diff --git a/autotests/test-qtextcodec-convert.cpp b/autotests/test-qtextcodec-convert.cpp deleted file mode 100644 index 62788354..00000000 --- a/autotests/test-qtextcodec-convert.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include "../iconv.hh" -#include -#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"