diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-04-25 13:33:03 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-28 01:16:20 +0200 |
commit | 1fc28ff56c93c33e4f0491c77920d8cee4e614b2 (patch) | |
tree | 66e7209fce11e68b62b5b1bba20b63431f7be1a3 /tests/auto/corelib/tools/qstring/tst_qstring.cpp | |
parent | da2c170aa25bc6e8fd6cd0788fae14ee455ce359 (diff) |
Re-enable casting to and from "ASCII" on tst_qstring.cpp
Turns out that we've had some old unit tests commented out that did not
compile. QString does not have a std::string constructor nor overloads
to many other methods. And std::string does not cast to char* on its
own. So these tests need to be removed.
Change-Id: I22df66fc3ccc68bc2840f2d83747234418e480f5
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 13b5593be1..4ac1221643 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -39,6 +39,16 @@ ** ****************************************************************************/ +#ifdef QT_NO_CAST_FROM_ASCII +# undef QT_NO_CAST_FROM_ASCII +#endif +#ifdef QT_NO_CAST_TO_ASCII +# undef QT_NO_CAST_TO_ASCII +#endif +#ifdef QT_ASCII_CAST_WARNINGS +# undef QT_ASCII_CAST_WARNINGS +#endif + #include <QtTest/QtTest> #include <qregexp.h> #include <qregularexpression.h> @@ -885,41 +895,11 @@ void tst_QString::constructorQByteArray() void tst_QString::STL() { -#ifndef QT_NO_CAST_TO_ASCII - QString qt( "QString" ); - std::string stdstr( "QString" ); - QString stlqt; - - // constructor - stlqt = QString( stdstr ); - QCOMPARE( stlqt, qt ); - - // assignment - stlqt = stdstr; - QCOMPARE( stlqt, qt ); - - std::string stdstr2 = stlqt; - QCOMPARE( stdstr2, stdstr ); - - // prepend - stlqt = QString(); - stlqt.prepend( stdstr ); - QCOMPARE( stlqt, qt ); - - // append - stlqt = QString(); - stlqt.append( stdstr ); - QCOMPARE( stlqt, qt ); - - // pathologics (null-strings not supported by many STLs, so test only empty strings) - stdstr = std::string(); - stlqt = stdstr; - QVERIFY( stlqt.isEmpty() ); - std::string stdstr3 = stlqt; - QVERIFY( !stdstr3.length() ); -#endif + QString stlqt = QString::fromStdString(stdstr); + QCOMPARE(stlqt, QString::fromLatin1(stdstr.c_str())); + QCOMPARE(stlqt.toStdString(), stdstr); const wchar_t arr[] = {'h', 'e', 'l', 'l', 'o', 0}; std::wstring stlStr = arr; |