summaryrefslogtreecommitdiff
path: root/qt4/tests
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2011-01-17 21:34:23 +0100
committerPino Toscano <pino@kde.org>2011-01-17 21:38:59 +0100
commit07a8808c22445c421f3064da7e5227dcbf40358b (patch)
tree2ba8a8f9f209b80bf8fe137b0a7d43a690c5487c /qt4/tests
parented367c08d788c88c49de770019bf826cfebb3e2c (diff)
fix unicodeToQString() to correctly decode the Unicode sequence
Use a UnicodeMap to convert the sequence to UTF-8, and convert from that to QString. Also, ignore the last character of the Unicode sequence if it is 0x0. Add a couple of testcases for it.
Diffstat (limited to 'qt4/tests')
-rw-r--r--qt4/tests/check_strings.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/qt4/tests/check_strings.cpp b/qt4/tests/check_strings.cpp
index 7c3e3ed9..1569a172 100644
--- a/qt4/tests/check_strings.cpp
+++ b/qt4/tests/check_strings.cpp
@@ -21,6 +21,8 @@
#include <poppler-qt4.h>
#include <poppler-private.h>
+#include <GlobalParams.h>
+
Q_DECLARE_METATYPE(GooString*)
Q_DECLARE_METATYPE(Unicode*)
@@ -51,11 +53,15 @@ void TestStrings::initTestCase()
{
qRegisterMetaType<GooString*>("GooString*");
qRegisterMetaType<Unicode*>("Unicode*");
+
+ globalParams = new GlobalParams();
}
void TestStrings::cleanupTestCase()
{
qDeleteAll(m_gooStrings);
+
+ delete globalParams;
}
void TestStrings::check_unicodeToQString_data()
@@ -90,6 +96,21 @@ void TestStrings::check_unicodeToQString_data()
u[1] = 0x0161;
QTest::newRow("a\u0161") << u << l << QString::fromUtf8("a\u0161");
}
+ {
+ const int l = 2;
+ Unicode *u = new Unicode[l];
+ u[0] = 0x5c01;
+ u[1] = 0x9762;
+ QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2") << u << l << QString::fromUtf8("\xe5\xb0\x81\xe9\x9d\xa2");
+ }
+ {
+ const int l = 3;
+ Unicode *u = new Unicode[l];
+ u[0] = 0x5c01;
+ u[1] = 0x9762;
+ u[2] = 0x0;
+ QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + 0") << u << l << QString::fromUtf8("\xe5\xb0\x81\xe9\x9d\xa2");
+ }
}
void TestStrings::check_unicodeToQString()