1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 //////////////// Some global configuration below ////////////////
36 // The following defines can be used to steer the kind of tests that
39 // With USE_AUTORUN, creator will automatically "execute" the commands
40 // in a comment following a BREAK_HERE line.
41 // The following commands are supported:
42 // // Check <name> <value> <type>
43 // - Checks whether the local variable is displayed with value and type.
44 // // CheckType <name> <type>
45 // - Checks whether the local variable is displayed with type.
46 // The value is untested, so it can be used with pointers values etc.
47 // that would change between test runs
49 // - Continues execution
51 // // Expand <name1>[ <name2> ...].
52 // - Expands local variables with given names.
53 // There should be at most one "Expand" line per BREAK_HERE,
54 // and this should placed on the line following the BREAK_HERE
55 // FIXME: Not implemented yet.
59 // If the line after a BREAK_HERE line does not contain one of the
60 // supported commands, the test stops.
62 // Same as 1, except that the debugger will stop automatically when
63 // a test after a BREAK_HERE failed
65 // Before using this, make sure that "Show a message box when receiving a signal"
66 // is disabled in "Tools" -> "Options..." -> "Debugger" -> "GDB".
71 // With USE_AUTOBREAK, the debugger will stop automatically on all
72 // lines containing the BREAK_HERE macro. This should be enabled
73 // during manual testing.
76 #define USE_AUTOBREAK 0
79 // With USE_UNINITIALIZED_AUTOBREAK, the debugger will stop automatically
80 // on all lines containing the BREAK_UNINITIALIZED_HERE macro.
81 // This should be enabled during manual testing.
83 #ifndef USE_UNINITIALIZED_AUTOBREAK
84 #define USE_UNINITIALIZED_AUTOBREAK 0
88 ////////////// No further global configuration below ////////////////
90 // AUTORUN is only sensibly with AUTOBREAK and without UNINITIALIZED_AUTOBREAK
94 #define USE_AUTOBREAK 1
95 #warning Switching on USE_AUTOBREAK
96 #endif // !USE_AUTOBREAK
97 #if USE_UNINITIALIZED_AUTOBREAK
98 #undef USE_UNINITIALIZED_AUTOBREAK
99 #define USE_UNINITIALIZED_AUTOBREAK 0
100 #warning Switching off USE_AUTOBREAK
101 #endif // USE_UNINITIALIZED_AUTOBREAK
105 #define USE_SCRIPTLIB 1
107 #define USE_SCRIPTLIB 0
110 #if QT_VERSION >= 0x040500
111 #define USE_SHARED_POINTER 1
113 #define USE_SHARED_POINTER 0
116 void dummyStatement(...) {}
118 #if USE_CXX11 && defined(__GNUC__) && defined(__STRICT_ANSI__)
119 #undef __STRICT_ANSI__ // working around compile error with MinGW
127 #include <QLinkedList>
134 #include <QStringList>
141 #if USE_SHARED_POINTER
142 #include <QSharedPointer>
148 //#include <QtGui/private/qfixed_p.h>
150 #include <QPainterPath>
153 #include <QTextCursor>
154 #include <QTextDocument>
157 #include <QScriptEngine>
158 #include <QScriptValue>
161 #include <QXmlAttributes>
163 #include <QHostAddress>
164 #include <QNetworkRequest>
166 #include <QApplication> // QWidgets: Separate module as of Qt 5
168 #include <QStandardItemModel>
190 #include "../simple/deep/deep/simple_test_app.h"
194 #include <boost/optional.hpp>
195 #include <boost/shared_ptr.hpp>
196 #include <boost/date_time.hpp>
197 #include <boost/date_time/gregorian/gregorian.hpp>
198 #include <boost/date_time/posix_time/posix_time.hpp>
202 #include <eigen2/Eigen/Core>
206 #include <private/qobject_p.h>
209 #if defined(__GNUC__) && !defined(__llvm__) && !defined(Q_OS_MAC)
210 # define USE_GCC_EXT 1
212 # include <ext/hash_set>
222 #include <xmmintrin.h>
228 # define BREAK_HERE __asm { int 3 }; __asm { mov eax, eax }
230 # define BREAK_HERE asm("int $3; mov %eax, %eax")
233 # define BREAK_HERE dummyStatement()
236 #if USE_UNINITIALIZED_AUTOBREAK
238 # define BREAK_UNINITIALIZED_HERE __asm { int 3 }; __asm { mov eax, eax }
240 # define BREAK_UNINITIALIZED_HERE asm("int $3; mov %eax, %eax")
243 # define BREAK_UNINITIALIZED_HERE dummyStatement()
248 uint qHash(const QMap<int, int> &) { return 0; }
249 uint qHash(const double & f) { return int(f); }
250 uint qHash(const QPointer<QObject> &p) { return (ulong)p.data(); }
259 SomeType(int a) : a(a) {}
269 // This tests multiple breakpoints. When a
271 template <typename T> class Vector
274 explicit Vector(int size)
275 : m_size(size), m_data(new T[size])
278 // Check size 10 int.
280 // Check there are multiple entries in the Breakpoint vie.
281 dummyStatement(this);
283 ~Vector() { delete [] m_data; }
284 int size() const { return m_size; }
293 Vector<float> vf(10);
294 Vector<double> vd(10);
296 dummyStatement(&vi, &vf, &vd, &vc);
299 } // namespace multibp
313 dummyStatement(&s, &t);
329 dummyStatement(&a, &b);
337 typedef QMap<QString, QString> Map;
339 QHash<QObject *, Map::iterator> h;
342 class X : virtual public Foo { public: X() { } };
344 class XX : virtual public Foo { public: XX() { } };
346 class Y : virtual public Foo { public: Y() { } };
348 class D : public X, public Y { int diamond; };
351 namespace peekandpoke {
353 void testAnonymousStructs()
357 struct { int i; int b; };
360 } a = { { 42, 43 } };
363 // CheckType a union {...}.
365 // Check a.d 9.1245819032257467e-313 double.
366 // Check a.f 5.88545355e-44 float.
373 // CheckType a union {...}.
375 // Check a.d 9.1245819012000775e-313 double.
376 // Check a.f 1.40129846e-45 float.
383 // CheckType a union {...}.
385 // Check a.d 9.1245819012494841e-313 double.
386 // Check a.f 2.80259693e-45 float.
394 void testComplexWatchers()
396 struct S { int a; double b; } s[10];
398 // Expand s and s[0].
399 // CheckType s peekandpoke::S [10].
402 // Manual: Watcher Context: "Add New Watcher".
403 // Manual: Type ['s[%d].a' % i for i in range(5)]
404 // Manual: Expand it, continue stepping. This should result in a list
405 // Manual: of five items containing the .a fields of s[0]..s[4].
406 for (int i = 0; i != 10; ++i)
412 void testQImageDisplay()
414 QImage im(QSize(200, 200), QImage::Format_RGB32);
415 im.fill(QColor(200, 10, 30).rgba());
418 pain.setPen(QPen(Qt::black, 5.0, Qt::SolidLine, Qt::RoundCap));
420 // Check im (200x200) QImage.
421 // CheckType pain QPainter.
424 pain.drawEllipse(20, 20, 160, 160);
428 // Manual: Toggle between "Normal" and "Displayed" in L&W Context Menu,
429 // Manual: entry "Display of Type QImage".
430 pain.drawArc(70, 115, 60, 30, 200 * 16, 140 * 16);
434 pain.setBrush(Qt::black);
438 pain.drawEllipse(65, 70, 15, 15);
442 // Manual: Toggle between "Normal" and "Displayed" in L&W Context Menu,
443 // Manual: entry "Display of Type QImage".
444 pain.drawEllipse(120, 70, 15, 15);
449 dummyStatement(&pain);
452 void testPeekAndPoke3()
454 testAnonymousStructs();
455 testComplexWatchers();
459 } // namespace peekandpoke
468 struct { int i; int b; };
478 Something() { a = b = 1; }
497 // Expand a a.#1 a.#2.
498 // CheckType a anon::TestAnonymous.
500 // CheckType a.#1.b int.
501 // CheckType a.#1.i int.
502 // CheckType a.#2.f float.
503 // CheckType a.d double.
511 // CheckType s anon::(anonymous namespace)::Something.
521 dummyStatement(&a, &s);
528 namespace qbytearray {
530 void testQByteArray1()
534 // Check ba "" QByteArray.
544 // Check ba "Hello"World" QByteArray.
545 // Check ba.0 72 'H' char.
546 // Check ba.11 0 '\0' char.
547 // Check ba.12 1 char.
548 // Check ba.13 2 char.
553 void testQByteArray2()
556 for (int i = 256; --i >= 0; )
558 QString s(10000, 'x');
559 std::string ss(10000, 'c');
561 // CheckType ba QByteArray.
562 // Check s "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." QString.
563 // Check ss "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc..." std::string.
565 dummyStatement(&ba, &ss, &s);
568 void testQByteArray3()
570 const char *str1 = "\356";
571 const char *str2 = "\xee";
572 const char *str3 = "\\ee";
573 QByteArray buf1(str1);
574 QByteArray buf2(str2);
575 QByteArray buf3(str3);
577 // Check buf1 "î" QByteArray.
578 // Check buf2 "î" QByteArray.
579 // Check buf3 "\ee" QByteArray.
580 // CheckType str1 char *.
582 dummyStatement(&buf1, &buf2, &buf3);
585 void testQByteArray()
592 } // namespace qbytearray
595 namespace catchthrow {
597 static void throwit1()
601 // Set a breakpoint on "throw" in the BreakWindow context menu
602 // before stepping further.
606 static void throwit()
611 void testCatchThrow()
619 dummyStatement(&gotit);
622 } // namespace catchthrow
625 namespace qdatetime {
632 // CheckType date QDate.
633 // Check date.(ISO) "" QString.
634 // Check date.(Locale) "" QString.
635 // Check date.(SystemLocale) "" QString.
636 // Check date.toString "" QString.
639 // Step, check display.
640 date = QDate::currentDate();
641 date = date.addDays(5);
642 date = date.addDays(5);
643 dummyStatement(&date);
651 // CheckType time QTime.
652 // Check time.(ISO) "" QString.
653 // Check time.(Locale) "" QString.
654 // Check time.(SystemLocale) "" QString.
655 // Check time.toString "" QString.
658 // Step, check display.
659 time = QTime::currentTime();
660 time = time.addSecs(5);
661 time = time.addSecs(5);
662 dummyStatement(&time);
670 // CheckType date QDateTime.
671 // Check date.(ISO) "" QString.
672 // Check date.(Locale) "" QString.
673 // Check date.(SystemLocale) "" QString.
674 // Check date.toString "" QString.
675 // Check date.toUTC QDateTime.
678 // Step, check display
679 date = QDateTime::currentDateTime();
680 date = date.addDays(5);
681 date = date.addDays(5);
682 dummyStatement(&date);
692 } // namespace qdatetime
702 // Check dir "/tmp" QDir.
703 // Check dir.absolutePath "/tmp" QString.
704 // Check dir.canonicalPath "/tmp" QString.
706 dummyStatement(&dir);
712 namespace qfileinfo {
716 QFile file("/tmp/t");
717 file.setObjectName("A QFile instance");
718 QFileInfo fi("/tmp/tt");
719 QString s = fi.absoluteFilePath();
721 // Check fi "/tmp/tt" QFileInfo.
722 // Check file "/tmp/t" QFile.
723 // Check s "/tmp/tt" QString.
725 dummyStatement(&file, &s);
728 } // namespace qfileinfo
735 QHash<QString, QList<int> > hash;
736 hash.insert("Hallo", QList<int>());
737 hash.insert("Welt", QList<int>() << 1);
738 hash.insert("!", QList<int>() << 1 << 2);
739 hash.insert("!", QList<int>() << 1 << 2);
741 // Expand hash hash.0 hash.1 hash.1.value hash.2 hash.2.value.
742 // Check hash <3 items> QHash<QString, QList<int>>.
743 // Check hash.0 QHashNode<QString, QList<int>>.
744 // Check hash.0.key "Hallo" QString.
745 // Check hash.0.value <0 items> QList<int>.
746 // Check hash.1 QHashNode<QString, QList<int>>.
747 // Check hash.1.key "Welt" QString.
748 // Check hash.1.value <1 items> QList<int>.
749 // Check hash.1.value.0 1 int.
750 // Check hash.2 QHashNode<QString, QList<int>>.
751 // Check hash.2.key "!" QString.
752 // Check hash.2.value <2 items> QList<int>.
753 // Check hash.2.value.0 1 int.
754 // Check hash.2.value.1 2 int.
756 dummyStatement(&hash);
761 QHash<int, float> hash;
766 // Check hash <2 items> QHash<int, float>.
767 // Check hash.22 22 float.
768 // Check hash.11 11 float.
770 dummyStatement(&hash);
775 QHash<QString, int> hash;
777 hash["123.0"] = 22.0;
778 hash["111111ss111128.0"] = 28.0;
779 hash["11124.0"] = 22.0;
780 hash["1111125.0"] = 22.0;
781 hash["11111126.0"] = 22.0;
782 hash["111111127.0"] = 27.0;
783 hash["111111111128.0"] = 28.0;
784 hash["111111111111111111129.0"] = 29.0;
786 // Expand hash hash.0 hash.8.
787 // Check hash <9 items> QHash<QString, int>.
788 // Check hash.0 QHashNode<QString, int>.
789 // Check hash.0.key "123.0" QString.
790 // Check hash.0.value 22 int.
791 // Check hash.8 QHashNode<QString, int>.
792 // Check hash.8.key "11124.0" QString.
793 // Check hash.8.value 22 int.
795 dummyStatement(&hash);
800 QHash<QByteArray, float> hash;
802 hash["123.0"] = 22.0;
803 hash["111111ss111128.0"] = 28.0;
804 hash["11124.0"] = 22.0;
805 hash["1111125.0"] = 22.0;
806 hash["11111126.0"] = 22.0;
807 hash["111111127.0"] = 27.0;
808 hash["111111111128.0"] = 28.0;
809 hash["111111111111111111129.0"] = 29.0;
811 // Expand hash hash.0 hash.8/
812 // Check hash <9 items> QHash<QByteArray, float>.
813 // Check hash.0 QHashNode<QByteArray, float>.
814 // Check hash.0.key "123.0" QByteArray.
815 // Check hash.0.value 22 float.
816 // Check hash.8 QHashNode<QByteArray, float>.
817 // Check hash.8.key "11124.0" QByteArray.
818 // Check hash.8.value 22 float.
820 dummyStatement(&hash);
825 QHash<int, QString> hash;
828 // Expand hash hash.0.
829 // Check hash <1 items> QHash<int, QString>.
830 // Check hash.0 QHashNode<int, QString>.
831 // Check hash.0.key 22 int.
832 // Check hash.0.value "22.0" QString.
834 dummyStatement(&hash);
839 QHash<QString, Foo> hash;
840 hash["22.0"] = Foo(22);
841 hash["33.0"] = Foo(33);
843 // Expand hash hash.0 hash.0.value hash.1.
844 // Check hash <2 items> QHash<QString, Foo>.
845 // Check hash.0 QHashNode<QString, Foo>.
846 // Check hash.0.key "22.0" QString.
847 // CheckType hash.0.value Foo.
848 // Check hash.0.value.a 22 int.
849 // Check hash.1 QHashNode<QString, Foo>.
850 // Check hash.1.key "33.0" QString.
851 // CheckType hash.1.value Foo.
853 dummyStatement(&hash);
859 QHash<QString, QPointer<QObject> > hash;
860 hash.insert("Hallo", QPointer<QObject>(&ob));
861 hash.insert("Welt", QPointer<QObject>(&ob));
862 hash.insert(".", QPointer<QObject>(&ob));
864 // Expand hash hash.0 hash.0.value hash.2.
865 // Check hash <3 items> QHash<QString, QPointer<QObject>>.
866 // Check hash.0 QHashNode<QString, QPointer<QObject>>.
867 // Check hash.0.key "Hallo" QString.
868 // CheckType hash.0.value QPointer<QObject>.
869 // CheckType hash.0.value.o QObject.
870 // Check hash.2 QHashNode<QString, QPointer<QObject>>.
871 // Check hash.2.key "." QString.
872 // CheckType hash.2.value QPointer<QObject>.
874 dummyStatement(&hash, &ob);
891 namespace qhostaddress {
893 void testQHostAddress()
895 QHostAddress ha1(129u * 256u * 256u * 256u + 130u);
896 QHostAddress ha2("127.0.0.1");
898 // Check ha1 129.0.0.130 QHostAddress.
899 // Check ha2 "127.0.0.1" QHostAddress.
901 dummyStatement(&ha1, &ha2);
904 } // namespace qhostaddress
911 // only works with Python dumper
912 QImage im(QSize(200, 200), QImage::Format_RGB32);
913 im.fill(QColor(200, 100, 130).rgba());
917 // Check im (200x200) QImage.
918 // CheckType pain QPainter.
921 pain.drawLine(2, 2, 130, 130);
922 pain.drawLine(4, 2, 130, 140);
923 pain.drawRect(30, 30, 80, 80);
925 dummyStatement(&pain, &im);
930 QImage im(QSize(200, 200), QImage::Format_RGB32);
931 im.fill(QColor(200, 100, 130).rgba());
934 pain.drawLine(2, 2, 130, 130);
936 QPixmap pm = QPixmap::fromImage(im);
938 // Check im (200x200) QImage.
939 // CheckType pain QPainter.
940 // Check pm (200x200) QPixmap.
942 dummyStatement(&im, &pm);
951 } // namespace painting
954 namespace qlinkedlist {
956 void testQLinkedListInt()
958 QLinkedList<int> list;
963 // Check list <2 items> QLinkedList<int>.
964 // Check list.0 101 int.
965 // Check list.1 102 int.
967 dummyStatement(&list);
970 void testQLinkedListUInt()
972 QLinkedList<uint> list;
977 // Check list <2 items> QLinkedList<unsigned int>.
978 // Check list.0 103 unsigned int.
979 // Check list.1 104 unsigned int.
981 dummyStatement(&list);
984 void testQLinkedListFooStar()
986 QLinkedList<Foo *> list;
987 list.append(new Foo(1));
989 list.append(new Foo(3));
991 // Expand list list.0 list.2.
992 // Check list <3 items> QLinkedList<Foo*>.
993 // CheckType list.0 Foo.
994 // Check list.0.a 1 int.
995 // Check list.1 0x0 Foo *.
996 // CheckType list.2 Foo.
997 // Check list.2.a 3 int.
999 dummyStatement(&list);
1002 void testQLinkedListULongLong()
1004 QLinkedList<qulonglong> list;
1009 // Check list <2 items> QLinkedList<unsigned long long>.
1010 // Check list.0 42 unsigned long long.
1011 // Check list.1 43 unsigned long long.
1013 dummyStatement(&list);
1016 void testQLinkedListFoo()
1018 QLinkedList<Foo> list;
1019 list.append(Foo(1));
1020 list.append(Foo(2));
1022 // Expand list list.0 list.1.
1023 // Check list <2 items> QLinkedList<Foo>.
1024 // CheckType list.0 Foo.
1025 // Check list.0.a 1 int.
1026 // CheckType list.1 Foo.
1027 // Check list.1.a 2 int.
1029 dummyStatement(&list);
1032 void testQLinkedListStdString()
1034 QLinkedList<std::string> list;
1035 list.push_back("aa");
1036 list.push_back("bb");
1039 // Check list <2 items> QLinkedList<std::string>.
1040 // Check list.0 "aa" std::string.
1041 // Check list.1 "bb" std::string.
1043 dummyStatement(&list);
1046 void testQLinkedList()
1048 testQLinkedListInt();
1049 testQLinkedListUInt();
1050 testQLinkedListFooStar();
1051 testQLinkedListULongLong();
1052 testQLinkedListFoo();
1053 testQLinkedListStdString();
1056 } // namespace qlinkedlist
1064 for (int i = 0; i < 10000; ++i)
1068 // Check big <10000 items> QList<int>.
1069 // Check big.0 0 int.
1070 // Check big.1999 1999 int.
1072 dummyStatement(&big);
1075 void testQListIntStar()
1079 // Check l <0 items> QList<int*>.
1081 l.append(new int(1));
1082 l.append(new int(2));
1083 l.append(new int(3));
1086 // Check l <3 items> QList<int*>.
1087 // CheckType l.0 int.
1088 // CheckType l.2 int.
1093 void testQListUInt()
1097 // Check l <0 items> QList<unsigned int>.
1104 // Check l <3 items> QList<unsigned int>.
1105 // Check l.0 101 unsigned int.
1106 // Check l.2 102 unsigned int.
1111 void testQListUShort()
1115 // Check l <0 items> QList<unsigned short>.
1122 // Check l <3 items> QList<unsigned short>.
1123 // Check l.0 101 unsigned short.
1124 // Check l.2 102 unsigned short.
1129 void testQListQChar()
1133 // Check l <0 items> QList<QChar>.
1135 l.append(QChar('a'));
1136 l.append(QChar('b'));
1137 l.append(QChar('c'));
1140 // Check l <3 items> QList<QChar>.
1141 // Check l.0 'a' (97) QChar.
1142 // Check l.2 'c' (99) QChar.
1147 void testQListQULongLong()
1149 QList<qulonglong> l;
1151 // Check l <0 items> QList<unsigned long long>.
1158 // Check l <3 items> QList<unsigned long long>.
1159 // CheckType l.0 unsigned long long.
1160 // CheckType l.2 unsigned long long.
1165 void testQListStdString()
1167 QList<std::string> l;
1169 // Check l <0 items> QList<std::string>.
1177 // Check l <4 items> QList<std::string>.
1178 // CheckType l.0 std::string.
1179 // CheckType l.3 std::string.
1188 // Check l <0 items> QList<Foo>.
1190 for (int i = 0; i < 100; ++i)
1191 l.push_back(i + 15);
1193 // Check l <100 items> QList<Foo>.
1195 // CheckType l.0 Foo.
1196 // CheckType l.99 Foo.
1202 // Check l <103 items> QList<Foo>.
1207 void testQListReverse()
1209 QList<int> l = QList<int>() << 1 << 2 << 3;
1210 typedef std::reverse_iterator<QList<int>::iterator> Reverse;
1211 Reverse rit(l.end());
1212 Reverse rend(l.begin());
1218 // Check l <3 items> QList<int>.
1222 // Check r <3 items> QList<int>.
1226 // CheckType rend qlist::Reverse.
1227 // CheckType rit qlist::Reverse.
1239 testQListQULongLong();
1240 testQListStdString();
1245 } // namespace qlist
1252 QLocale loc = QLocale::system();
1253 //QString s = loc.name();
1255 QLocale::MeasurementSystem m = loc.measurementSystem();
1257 // CheckType loc QLocale.
1258 // CheckType m QLocale::MeasurementSystem.
1260 dummyStatement(&loc, &m);
1263 } // namespace qlocale
1268 void testQMapUIntStringList()
1270 QMap<uint, QStringList> map;
1271 map[11] = QStringList() << "11";
1272 map[22] = QStringList() << "22";
1274 // Expand map map.0 map.0.value map.1 map.1.value.
1275 // Check map <2 items> QMap<unsigned int, QStringList>.
1276 // Check map.0 QMapNode<unsigned int, QStringList>.
1277 // Check map.0.key 11 unsigned int.
1278 // Check map.0.value <1 items> QStringList.
1279 // Check map.0.value.0 "11" QString.
1280 // Check map.1 QMapNode<unsigned int, QStringList>.
1281 // Check map.1.key 22 unsigned int.
1282 // Check map.1.value <1 items> QStringList.
1283 // Check map.1.value.0 "22" QString.
1285 dummyStatement(&map);
1288 void testQMapUIntStringListTypedef()
1290 // only works with Python dumper
1291 typedef QMap<uint, QStringList> T;
1293 map[11] = QStringList() << "11";
1294 map[22] = QStringList() << "22";
1296 // Check map <2 items> qmap::T.
1298 dummyStatement(&map);
1301 void testQMapUIntFloat()
1303 QMap<uint, float> map;
1308 // Check map <2 items> QMap<unsigned int, float>.
1309 // Check map.11 11 float.
1310 // Check map.22 22 float.
1312 dummyStatement(&map);
1315 void testQMapStringFloat()
1317 QMap<QString, float> map;
1320 // Expand map map.0.
1321 // Check map <1 items> QMap<QString, float>.
1322 // Check map.0 QMapNode<QString, float>.
1323 // Check map.0.key "22.0" QString.
1324 // Check map.0.value 22 float.
1326 dummyStatement(&map);
1329 void testQMapIntString()
1331 QMap<int, QString> map;
1334 // Expand map map.0.
1335 // Check map <1 items> QMap<int, QString>.
1336 // Check map.0 QMapNode<int, QString>.
1337 // Check map.0.key 22 int.
1338 // Check map.0.value "22.0" QString.
1340 dummyStatement(&map);
1343 void testQMapStringFoo()
1345 QMap<QString, Foo> map;
1346 map["22.0"] = Foo(22);
1347 map["33.0"] = Foo(33);
1349 // Expand map map.0 map.0.key map.0.value map.1 map.1.value.
1350 // Check map <2 items> QMap<QString, Foo>.
1351 // Check map.0 QMapNode<QString, Foo>.
1352 // Check map.0.key "22.0" QString.
1353 // CheckType map.0.value Foo.
1354 // Check map.0.value.a 22 int.
1355 // Check map.1 QMapNode<QString, Foo>.
1356 // Check map.1.key "33.0" QString.
1357 // CheckType map.1.value Foo.
1358 // Check map.1.value.a 33 int.
1360 dummyStatement(&map);
1363 void testQMapStringPointer()
1365 // only works with Python dumper
1367 QMap<QString, QPointer<QObject> > map;
1368 map.insert("Hallo", QPointer<QObject>(&ob));
1369 map.insert("Welt", QPointer<QObject>(&ob));
1370 map.insert(".", QPointer<QObject>(&ob));
1372 // Expand map map.0 map.0.key map.0.value map.1 map.2.
1373 // Check map <3 items> QMap<QString, QPointer<QObject>>.
1374 // Check map.0 QMapNode<QString, QPointer<QObject>>.
1375 // Check map.0.key "." QString.
1376 // CheckType map.0.value QPointer<QObject>.
1377 // CheckType map.0.value.o QObject.
1378 // Check map.1 QMapNode<QString, QPointer<QObject>>.
1379 // Check map.1.key "Hallo" QString.
1380 // Check map.2 QMapNode<QString, QPointer<QObject>>.
1381 // Check map.2.key "Welt" QString.
1383 dummyStatement(&map);
1386 void testQMapStringList()
1388 // only works with Python dumper
1389 QList<nsA::nsB::SomeType *> x;
1390 x.append(new nsA::nsB::SomeType(1));
1391 x.append(new nsA::nsB::SomeType(2));
1392 x.append(new nsA::nsB::SomeType(3));
1393 QMap<QString, QList<nsA::nsB::SomeType *> > map;
1399 // Expand map map.0 map.0.key map.0.value map.1 map.1.value.1 map.1.value.2 map.3 map.3.value map.3.value.2.
1400 // Check map <4 items> QMap<QString, QList<nsA::nsB::SomeType*>>.
1401 // Check map.0 QMapNode<QString, QList<nsA::nsB::SomeType*>>.
1402 // Check map.0.key "1" QString.
1403 // Check map.0.value <3 items> QList<nsA::nsB::SomeType*>.
1404 // CheckType map.0.value.0 nsA::nsB::SomeType.
1405 // Check map.0.value.0.a 1 int.
1406 // CheckType map.0.value.1 nsA::nsB::SomeType.
1407 // Check map.0.value.1.a 2 int.
1408 // CheckType map.0.value.2 nsA::nsB::SomeType.
1409 // Check map.0.value.2.a 3 int.
1410 // Check map.3 QMapNode<QString, QList<nsA::nsB::SomeType*>>.
1411 // Check map.3.key "foo" QString.
1412 // Check map.3.value <3 items> QList<nsA::nsB::SomeType*>.
1413 // CheckType map.3.value.2 nsA::nsB::SomeType.
1414 // Check map.3.value.2.a 3 int.
1415 // Check x <3 items> QList<nsA::nsB::SomeType*>.
1417 dummyStatement(&map);
1420 void testQMultiMapUintFloat()
1422 QMultiMap<uint, float> map;
1423 map.insert(11, 11.0);
1424 map.insert(22, 22.0);
1425 map.insert(22, 33.0);
1426 map.insert(22, 34.0);
1427 map.insert(22, 35.0);
1428 map.insert(22, 36.0);
1431 // Check map <6 items> QMultiMap<unsigned int, float>.
1432 // Check map.0 11 float.
1433 // Check map.5 22 float.
1435 dummyStatement(&map);
1438 void testQMultiMapStringFloat()
1440 QMultiMap<QString, float> map;
1441 map.insert("22.0", 22.0);
1443 // Expand map map.0.
1444 // Check map <1 items> QMultiMap<QString, float>.
1445 // Check map.0 QMapNode<QString, float>.
1446 // Check map.0.key "22.0" QString.
1447 // Check map.0.value 22 float.
1449 dummyStatement(&map);
1452 void testQMultiMapIntString()
1454 QMultiMap<int, QString> map;
1455 map.insert(22, "22.0");
1457 // Expand map map.0.
1458 // Check map <1 items> QMultiMap<int, QString>.
1459 // Check map.0 QMapNode<int, QString>.
1460 // Check map.0.key 22 int.
1461 // Check map.0.value "22.0" QString.
1463 dummyStatement(&map);
1466 void testQMultiMapStringFoo()
1468 QMultiMap<QString, Foo> map;
1469 map.insert("22.0", Foo(22));
1470 map.insert("33.0", Foo(33));
1471 map.insert("22.0", Foo(22));
1473 // Expand map map.0 map.0.value.
1474 // Check map <3 items> QMultiMap<QString, Foo>.
1475 // Check map.0 QMapNode<QString, Foo>.
1476 // Check map.0.key "22.0" QString.
1477 // CheckType map.0.value Foo.
1478 // Check map.0.value.a 22 int.
1479 // Check map.2 QMapNode<QString, Foo>.
1481 dummyStatement(&map);
1484 void testQMultiMapStringPointer()
1487 QMultiMap<QString, QPointer<QObject> > map;
1488 map.insert("Hallo", QPointer<QObject>(&ob));
1489 map.insert("Welt", QPointer<QObject>(&ob));
1490 map.insert(".", QPointer<QObject>(&ob));
1491 map.insert(".", QPointer<QObject>(&ob));
1493 // Expand map map.0 map.1 map.2 map.3.
1494 // Check map <4 items> QMultiMap<QString, QPointer<QObject>>.
1495 // Check map.0 QMapNode<QString, QPointer<QObject>>.
1496 // Check map.0.key "." QString.
1497 // CheckType map.0.value QPointer<QObject>.
1498 // Check map.1 QMapNode<QString, QPointer<QObject>>.
1499 // Check map.1.key "." QString.
1500 // Check map.2 QMapNode<QString, QPointer<QObject>>.
1501 // Check map.2.key "Hallo" QString.
1502 // Check map.3 QMapNode<QString, QPointer<QObject>>.
1503 // Check map.3.key "Welt" QString.
1505 dummyStatement(&map);
1510 testQMapUIntStringList();
1511 testQMapUIntStringListTypedef();
1512 testQMapUIntFloat();
1513 testQMapStringFloat();
1514 testQMapIntString();
1515 testQMapStringFoo();
1516 testQMapStringPointer();
1517 testQMapStringList();
1518 testQMultiMapUintFloat();
1519 testQMultiMapStringFloat();
1520 testQMultiMapIntString();
1521 testQMultiMapStringFoo();
1522 testQMapUIntStringList();
1523 testQMultiMapStringFoo();
1524 testQMultiMapStringPointer();
1534 // This checks whether signal-slot connections are displayed.
1536 parent.setObjectName("A Parent");
1537 QObject child(&parent);
1538 child.setObjectName("A Child");
1539 QObject::connect(&child, SIGNAL(destroyed()), &parent, SLOT(deleteLater()));
1540 QObject::disconnect(&child, SIGNAL(destroyed()), &parent, SLOT(deleteLater()));
1541 child.setObjectName("A renamed Child");
1543 // Check child "A renamed Child" QObject.
1544 // Check parent "A Parent" QObject.
1546 dummyStatement(&parent, &child);
1552 struct Ui { Ui() { w = 0; } QWidget *w; };
1554 class TestObject : public QObject
1558 TestObject(QObject *parent = 0) : QObject(parent)
1559 { m_ui = new Ui; m_ui->w = new QWidget; }
1561 Q_PROPERTY(QString myProp1 READ myProp1 WRITE setMyProp1)
1562 QString myProp1() const { return m_myProp1; }
1563 Q_SLOT void setMyProp1(const QString&mt) { m_myProp1 = mt; }
1565 Q_PROPERTY(QString myProp2 READ myProp2 WRITE setMyProp2)
1566 QString myProp2() const { return m_myProp2; }
1567 Q_SLOT void setMyProp2(const QString&mt) { m_myProp2 = mt; }
1576 } // namespace Names
1580 //QString longString = QString(10000, QLatin1Char('A'));
1582 Names::Bar::TestObject test;
1583 test.setMyProp1("HELLO");
1584 test.setMyProp2("WORLD");
1585 QString s = test.myProp1();
1586 s += test.myProp2();
1588 // Check s "HELLOWORLD" QString.
1589 // Check test "" qobject::Names::Bar::TestObject.
1595 QAction act("xxx", &app);
1596 QString t = act.text();
1606 ob.setObjectName("An Object");
1607 ob.setProperty("USER DEFINED 1", 44);
1608 ob.setProperty("USER DEFINED 2", QStringList() << "FOO" << "BAR");
1610 ob1.setObjectName("Another Object");
1612 QObject::connect(&ob, SIGNAL(destroyed()), &ob1, SLOT(deleteLater()));
1613 QObject::connect(&ob, SIGNAL(destroyed()), &ob1, SLOT(deleteLater()));
1614 //QObject::connect(&app, SIGNAL(lastWindowClosed()), &ob, SLOT(deleteLater()));
1618 QList<QObject *> obs;
1623 ob1.setObjectName("A Subobject");
1627 class Sender : public QObject
1631 Sender() { setObjectName("Sender"); }
1632 void doEmit() { emit aSignal(); }
1637 class Receiver : public QObject
1641 Receiver() { setObjectName("Receiver"); }
1644 QObject *s = sender();
1646 qDebug() << "SENDER: " << s;
1648 qDebug() << "NO SENDER";
1653 void testSignalSlot()
1657 QObject::connect(&sender, SIGNAL(aSignal()), &receiver, SLOT(aSlot()));
1659 // Single step through signal emission.
1661 dummyStatement(&sender, &receiver);
1666 class DerivedObjectPrivate : public QObjectPrivate
1669 DerivedObjectPrivate() {
1671 m_extraY.append("xxx");
1675 QStringList m_extraY;
1681 class DerivedObject : public QObject
1686 DerivedObject() : QObject(*new DerivedObjectPrivate, 0) {}
1688 Q_PROPERTY(int x READ x WRITE setX)
1689 Q_PROPERTY(QStringList y READ y WRITE setY)
1690 Q_PROPERTY(uint z READ z WRITE setZ)
1694 QStringList y() const;
1695 void setY(QStringList y);
1700 Q_DECLARE_PRIVATE(DerivedObject)
1703 int DerivedObject::x() const
1705 Q_D(const DerivedObject);
1709 void DerivedObject::setX(int x)
1713 d->m_extraA = !d->m_extraA;
1714 d->m_extraB = !d->m_extraB;
1717 QStringList DerivedObject::y() const
1719 Q_D(const DerivedObject);
1723 void DerivedObject::setY(QStringList y)
1729 uint DerivedObject::z() const
1731 Q_D(const DerivedObject);
1735 void DerivedObject::setZ(uint z)
1743 void testQObjectData()
1745 // This checks whether QObject-derived classes with Q_PROPERTYs
1746 // are displayed properly.
1750 // Expand ob ob.properties.
1751 // Check ob.properties.x 43 QVariant (int).
1754 // expand ob and ob.properties
1755 // step, and check whether x gets updated.
1760 // Expand ob ob.properties.
1761 // Check ob.properties.x 26 QVariant (int).
1774 } // namespace qobject
1782 // Works with Python dumpers only.
1783 QRegExp re(QString("a(.*)b(.*)c"));
1785 // Check re "a(.*)b(.*)c" QRegExp.
1787 QString str1 = "a1121b344c";
1788 QString str2 = "Xa1121b344c";
1790 // Check str1 "a1121b344c" QString.
1791 // Check str2 "Xa1121b344c" QString.
1793 int pos2 = re.indexIn(str2);
1794 int pos1 = re.indexIn(str1);
1796 // Check pos1 0 int.
1797 // Check pos2 1 int.
1799 dummyStatement(&pos1, &pos2);
1802 } // namespace qregexp
1811 // Check s (0, 0) QPoint.
1813 // Step over, check display looks sane.
1814 s = QPoint(100, 200);
1816 // Check s (100, 200) QPoint.
1825 // Check s (0, 0) QPointF.
1827 // Step over, check display looks sane.
1828 s = QPointF(100, 200);
1830 // Check s (100, 200) QPointF.
1839 // Check rect 0x0+0+0 QRect.
1841 // Step over, check display looks sane.
1842 rect = QRect(100, 100, 200, 200);
1844 // Check rect 200x200+100+100 QRect.
1846 dummyStatement(&rect);
1853 // Check rect 0x0+0+0 QRectF.
1855 // Step over, check display looks sane.
1856 rect = QRectF(100, 100, 200, 200);
1858 // Check rect 200x200+100+100 QRectF.
1860 dummyStatement(&rect);
1867 // Check s (-1, -1) QSize.
1869 s = QSize(100, 200);
1871 // Check s (100, 200) QSize.
1880 // Check s (-1, -1) QSizeF.
1882 s = QSizeF(100, 200);
1884 // Check s (100, 200) QSizeF.
1899 } // namespace qrect
1906 // Works with Python dumpers only.
1909 // Check region <empty> QRegion.
1911 // Step over until end, check display looks sane.
1912 region += QRect(100, 100, 200, 200);
1915 // Check region <1 items> QRegion.
1916 // CheckType region.extents QRect.
1917 // Check region.innerArea 40000 int.
1918 // CheckType region.innerRect QRect.
1919 // Check region.numRects 1 int.
1920 // Check region.rects <0 items> QVector<QRect>.
1922 region += QRect(300, 300, 400, 500);
1925 // Check region <2 items> QRegion.
1926 // CheckType region.extents QRect.
1927 // Check region.innerArea 200000 int.
1928 // CheckType region.innerRect QRect.
1929 // Check region.numRects 2 int.
1930 // Check region.rects <2 items> QVector<QRect>.
1932 region += QRect(500, 500, 600, 600);
1935 // Check region <4 items> QRegion.
1936 // CheckType region.extents QRect.
1937 // Check region.innerArea 360000 int.
1938 // CheckType region.innerRect QRect.
1939 // Check region.numRects 4 int.
1940 // Check region.rects <8 items> QVector<QRect>.
1942 region += QRect(500, 500, 600, 600);
1944 // Check region <4 items> QRegion.
1946 region += QRect(500, 500, 600, 600);
1948 // Check region <4 items> QRegion.
1950 region += QRect(500, 500, 600, 600);
1952 // Check region <4 items> QRegion.
1954 dummyStatement(®ion);
1957 } // namespace qregion
1964 QString dir = QDir::currentPath();
1966 QLibrary lib(dir + "/libsimple_test_plugin.so");
1969 dir = QFileInfo(dir + "/../..").canonicalPath();
1970 QLibrary lib(dir + "/libsimple_test_plugin.dylib");
1973 QLibrary lib(dir + "/debug/simple_test_plugin.dll");
1976 QLibrary lib(dir + "/libsimple_test_plugin.dll");
1979 // CheckType dir QString.
1980 // Check lib "" QLibrary.
1981 // Check name <not accessible> QString.
1982 // CheckType res int.
1985 int (*foo)() = (int(*)()) lib.resolve("pluginTest");
1986 QString name = lib.fileName();
1997 name = lib.errorString();
1999 dummyStatement(&name, &res);
2002 } // namespace plugin
2007 void testQSettings()
2009 // Note: Construct a QCoreApplication first.
2010 QSettings settings("/tmp/test.ini", QSettings::IniFormat);
2011 QVariant value = settings.value("item1","").toString();
2014 // Check settings "" QSettings.
2015 // Check settings.@1 "" QObject.
2016 // Check value "" QVariant (QString).
2018 dummyStatement(&settings, &value);
2021 void testNullPointerDeref()
2026 return; // Uncomment.
2030 void testEndlessRecursion()
2035 return; // Uncomment.
2036 testEndlessRecursion();
2039 void testEndlessLoop()
2043 // Breakpoint at "while" will stop only once
2044 // Hitting "Pause" button might show backtrace of different thread
2048 // Jump over next line.
2055 void testUncaughtException()
2060 // Jump over next line.
2065 void testApplicationStart(QCoreApplication *app)
2067 QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö");
2069 l.setObjectName("Some Label");
2071 // Jump over next line.
2074 dummyStatement(&app);
2077 void testFinal(QCoreApplication *app)
2079 // This contains all "final" tests that do not allow proceeding
2080 // with further tests.
2084 testNullPointerDeref();
2086 testEndlessRecursion();
2087 testUncaughtException();
2088 testApplicationStart(app);
2091 } // namespace final
2103 // Check s <2 items> QSet<int>.
2104 // Check s.22 22 int.
2105 // Check s.11 11 int.
2117 // Check s <2 items> QSet<QString>.
2118 // Check s.0 "11.0" QString.
2119 // Check s.1 "22.0" QString.
2127 QSet<QPointer<QObject> > s;
2128 QPointer<QObject> ptr(&ob);
2134 // Check s <1 items> QSet<QPointer<QObject>>.
2135 // CheckType s.0 QPointer<QObject>.
2137 dummyStatement(&ptr, &s);
2150 namespace qsharedpointer {
2152 #if USE_SHARED_POINTER
2154 class EmployeeData : public QSharedData
2157 EmployeeData() : id(-1) { name.clear(); }
2158 EmployeeData(const EmployeeData &other)
2159 : QSharedData(other), id(other.id), name(other.name) { }
2169 Employee() { d = new EmployeeData; }
2170 Employee(int id, QString name) {
2171 d = new EmployeeData;
2175 Employee(const Employee &other)
2179 void setId(int id) { d->id = id; }
2180 void setName(QString name) { d->name = name; }
2182 int id() const { return d->id; }
2183 QString name() const { return d->name; }
2186 QSharedDataPointer<EmployeeData> d;
2190 void testQSharedPointer1()
2192 QSharedPointer<int> ptr(new int(43));
2193 QSharedPointer<int> ptr2 = ptr;
2194 QSharedPointer<int> ptr3 = ptr;
2196 dummyStatement(&ptr, &ptr2, &ptr3);
2199 void testQSharedPointer2()
2201 QSharedPointer<QString> ptr(new QString("hallo"));
2202 QSharedPointer<QString> ptr2 = ptr;
2203 QSharedPointer<QString> ptr3 = ptr;
2205 dummyStatement(&ptr, &ptr2, &ptr3);
2208 void testQSharedPointer3()
2210 QSharedPointer<int> iptr(new int(43));
2211 QWeakPointer<int> ptr(iptr);
2212 QWeakPointer<int> ptr2 = ptr;
2213 QWeakPointer<int> ptr3 = ptr;
2215 dummyStatement(&ptr, &ptr2, &ptr3);
2218 void testQSharedPointer4()
2220 QSharedPointer<QString> sptr(new QString("hallo"));
2221 QWeakPointer<QString> ptr(sptr);
2222 QWeakPointer<QString> ptr2 = ptr;
2223 QWeakPointer<QString> ptr3 = ptr;
2225 dummyStatement(&ptr, &ptr2, &ptr3);
2228 void testQSharedPointer5()
2230 QSharedPointer<Foo> fptr(new Foo(1));
2231 QWeakPointer<Foo> ptr(fptr);
2232 QWeakPointer<Foo> ptr2 = ptr;
2233 QWeakPointer<Foo> ptr3 = ptr;
2235 dummyStatement(&ptr, &ptr2, &ptr3);
2238 void testQSharedPointer()
2240 testQSharedPointer1();
2241 testQSharedPointer2();
2242 testQSharedPointer3();
2243 testQSharedPointer4();
2244 testQSharedPointer5();
2249 void testQSharedPointer() {}
2253 } // namespace qsharedpointer
2258 void testQXmlAttributes()
2260 // only works with Python dumper
2261 QXmlAttributes atts;
2262 atts.append("name1", "uri1", "localPart1", "value1");
2263 atts.append("name2", "uri2", "localPart2", "value2");
2264 atts.append("name3", "uri3", "localPart3", "value3");
2266 // Expand atts atts.attList atts.attList.1 atts.attList.2.
2267 // CheckType atts QXmlAttributes.
2268 // CheckType atts.[vptr] .
2269 // Check atts.attList <3 items> QXmlAttributes::AttributeList.
2270 // CheckType atts.attList.0 QXmlAttributes::Attribute.
2271 // Check atts.attList.0.localname "localPart1" QString.
2272 // Check atts.attList.0.qname "name1" QString.
2273 // Check atts.attList.0.uri "uri1" QString.
2274 // Check atts.attList.0.value "value1" QString.
2275 // CheckType atts.attList.1 QXmlAttributes::Attribute.
2276 // Check atts.attList.1.localname "localPart2" QString.
2277 // Check atts.attList.1.qname "name2" QString.
2278 // Check atts.attList.1.uri "uri2" QString.
2279 // Check atts.attList.1.value "value2" QString.
2280 // CheckType atts.attList.2 QXmlAttributes::Attribute.
2281 // Check atts.attList.2.localname "localPart3" QString.
2282 // Check atts.attList.2.qname "name3" QString.
2283 // Check atts.attList.2.uri "uri3" QString.
2284 // Check atts.attList.2.value "value3" QString.
2285 // CheckType atts.d QXmlAttributesPrivate.
2293 namespace stdarray {
2298 std::array<int, 4> a = { { 1, 2, 3, 4} };
2301 // Check a <4 items> std::array<int, 4u>.
2307 } // namespace stdcomplex
2311 namespace stdcomplex {
2313 void testStdComplex()
2315 std::complex<double> c(1, 2);
2318 // Check c (1.000000, 2.000000) std::complex<double>.
2323 } // namespace stdcomplex
2326 namespace stddeque {
2328 void testStdDequeInt()
2330 std::deque<int> deque;
2335 // Check deque <2 items> std::deque<int>.
2336 // Check deque.0 1 int.
2337 // Check deque.1 2 int.
2339 dummyStatement(&deque);
2342 void testStdDequeIntStar()
2344 // This is not supposed to work with the compiled dumpers.
2345 std::deque<int *> deque;
2346 deque.push_back(new int(1));
2348 deque.push_back(new int(2));
2351 // Check deque <3 items> std::deque<int*>.
2352 // CheckType deque.0 int.
2353 // Check deque.1 0x0 int *.
2358 dummyStatement(&deque);
2361 void testStdDequeFoo()
2363 std::deque<Foo> deque;
2365 deque.push_front(2);
2367 // Expand deque deque.0 deque.1.
2368 // Check deque <2 items> std::deque<Foo>.
2369 // CheckType deque.0 Foo.
2370 // Check deque.0.a 2 int.
2371 // CheckType deque.1 Foo.
2372 // Check deque.1.a 1 int.
2374 dummyStatement(&deque);
2377 void testStdDequeFooStar()
2379 std::deque<Foo *> deque;
2380 deque.push_back(new Foo(1));
2381 deque.push_back(new Foo(2));
2383 // Expand deque deque.0 deque.1.
2384 // Check deque <2 items> std::deque<Foo*>.
2385 // CheckType deque.0 Foo.
2386 // Check deque.0.a 1 int.
2387 // CheckType deque.1 Foo.
2388 // Check deque.1.a 2 int.
2390 dummyStatement(&deque);
2396 testStdDequeIntStar();
2398 testStdDequeFooStar();
2401 } // namespace stddeque
2404 namespace stdhashset {
2406 void testStdHashSet()
2408 // This is not supposed to work with the compiled dumpers.
2410 using namespace __gnu_cxx;
2418 // Check h <4 items> __gnu__cxx::hash_set<int>.
2419 // Check h.0 194 int.
2428 } // namespace stdhashset
2433 void testStdListInt()
2435 std::list<int> list;
2440 // Check list <2 items> std::list<int>.
2441 // Check list.0 1 int.
2442 // Check list.1 2 int.
2444 dummyStatement(&list);
2447 void testStdListIntStar()
2449 std::list<int *> list;
2450 list.push_back(new int(1));
2452 list.push_back(new int(2));
2455 // Check list <3 items> std::list<int*>.
2456 // CheckType list.0 int.
2457 // Check list.1 0x0 int *.
2458 // CheckType list.2 int.
2460 dummyStatement(&list);
2463 void testStdListIntBig()
2465 // This is not supposed to work with the compiled dumpers.
2466 std::list<int> list;
2467 for (int i = 0; i < 10000; ++i)
2471 // Check list <more than 1000 items> std::list<int>.
2472 // Check list.0 0 int.
2473 // Check list.999 999 int.
2475 dummyStatement(&list);
2478 void testStdListFoo()
2480 std::list<Foo> list;
2484 // Expand list list.0 list.1.
2485 // Check list <2 items> std::list<Foo>.
2486 // CheckType list.0 Foo.
2487 // Check list.0.a 15 int.
2488 // CheckType list.1 Foo.
2489 // Check list.1.a 16 int.
2491 dummyStatement(&list);
2494 void testStdListFooStar()
2496 std::list<Foo *> list;
2497 list.push_back(new Foo(1));
2499 list.push_back(new Foo(2));
2501 // Expand list list.0 list.2.
2502 // Check list <3 items> std::list<Foo*>.
2503 // CheckType list.0 Foo.
2504 // Check list.0.a 1 int.
2505 // Check list.1 0x0 Foo *.
2506 // CheckType list.2 Foo.
2507 // Check list.2.a 2 int.
2509 dummyStatement(&list);
2512 void testStdListBool()
2514 std::list<bool> list;
2515 list.push_back(true);
2516 list.push_back(false);
2519 // Check list <2 items> std::list<bool>.
2520 // Check list.0 true bool.
2521 // Check list.1 false bool.
2523 dummyStatement(&list);
2529 testStdListIntStar();
2530 testStdListIntBig();
2532 testStdListFooStar();
2536 } // namespace stdlist
2541 void testStdMapStringFoo()
2543 // This is not supposed to work with the compiled dumpers.
2544 std::map<QString, Foo> map;
2545 map["22.0"] = Foo(22);
2546 map["33.0"] = Foo(33);
2547 map["44.0"] = Foo(44);
2549 // Expand map map.0 map.0.second map.2 map.2.second.
2550 // Check map <3 items> std::map<QString, Foo>.
2551 // Check map.0 std::pair<QString const, Foo>.
2552 // Check map.0.first "22.0" QString.
2553 // CheckType map.0.second Foo.
2554 // Check map.0.second.a 22 int.
2555 // Check map.1 std::pair<QString const, Foo>.
2556 // Check map.2.first "44.0" QString.
2557 // CheckType map.2.second Foo.
2558 // Check map.2.second.a 44 int.
2560 dummyStatement(&map);
2563 void testStdMapCharStarFoo()
2565 std::map<const char *, Foo> map;
2566 map["22.0"] = Foo(22);
2567 map["33.0"] = Foo(33);
2569 // Expand map map.0 map.0.first map.0.second map.1 map.1.second.
2570 // Check map <2 items> std::map<char const*, Foo>.
2571 // Check map.0 std::pair<char const* const, Foo>.
2572 // CheckType map.0.first char *.
2573 // Check map.0.first.*first 50 '2' char.
2574 // CheckType map.0.second Foo.
2575 // Check map.0.second.a 22 int.
2576 // Check map.1 std::pair<char const* const, Foo>.
2577 // CheckType map.1.first char *.
2578 // Check map.1.first.*first 51 '3' char.
2579 // CheckType map.1.second Foo.
2580 // Check map.1.second.a 33 int.
2582 dummyStatement(&map);
2585 void testStdMapUIntUInt()
2587 std::map<uint, uint> map;
2592 // Check map <2 items> std::map<unsigned int, unsigned int>.
2593 // Check map.11 1 unsigned int.
2594 // Check map.22 2 unsigned int.
2596 dummyStatement(&map);
2599 void testStdMapUIntStringList()
2601 std::map<uint, QStringList> map;
2602 map[11] = QStringList() << "11";
2603 map[22] = QStringList() << "22";
2605 // Expand map map.0 map.0.first map.0.second map.1 map.1.second.
2606 // Check map <2 items> std::map<unsigned int, QStringList>.
2607 // Check map.0 std::pair<unsigned int const, QStringList>.
2608 // Check map.0.first 11 unsigned int.
2609 // Check map.0.second <1 items> QStringList.
2610 // Check map.0.second.0 "11" QString.
2611 // Check map.1 std::pair<unsigned int const, QStringList>.
2612 // Check map.1.first 22 unsigned int.
2613 // Check map.1.second <1 items> QStringList.
2614 // Check map.1.second.0 "22" QString.
2616 dummyStatement(&map);
2619 void testStdMapUIntStringListTypedef()
2621 typedef std::map<uint, QStringList> T;
2623 map[11] = QStringList() << "11";
2624 map[22] = QStringList() << "22";
2626 // Check map <2 items> stdmap::T.
2628 dummyStatement(&map);
2631 void testStdMapUIntFloat()
2633 std::map<uint, float> map;
2638 // Check map <2 items> std::map<unsigned int, float>.
2639 // Check map.11 11 float.
2640 // Check map.22 22 float.
2642 dummyStatement(&map);
2645 void testStdMapStringFloat()
2647 std::map<QString, float> map;
2651 // Expand map map.0 map.1.
2652 // Check map <2 items> std::map<QString, float>.
2653 // Check map.0 std::pair<QString const, float>.
2654 // Check map.0.first "11.0" QString.
2655 // Check map.0.second 11 float.
2656 // Check map.1 std::pair<QString const, float>.
2657 // Check map.1.first "22.0" QString.
2658 // Check map.1.second 22 float.
2660 dummyStatement(&map);
2663 void testStdMapIntString()
2665 std::map<int, QString> map;
2669 // Expand map map.0 map.1.
2670 // Check map <2 items> std::map<int, QString>.
2671 // Check map.0 std::pair<int const, QString>.
2672 // Check map.0.first 11 int.
2673 // Check map.0.second "11.0" QString.
2674 // Check map.1 std::pair<int const, QString>.
2675 // Check map.1.first 22 int.
2676 // Check map.1.second "22.0" QString.
2678 dummyStatement(&map);
2681 void testStdMapStringPointer()
2684 std::map<QString, QPointer<QObject> > map;
2685 map["Hallo"] = QPointer<QObject>(&ob);
2686 map["Welt"] = QPointer<QObject>(&ob);
2687 map["."] = QPointer<QObject>(&ob);
2689 // Expand map map.0 map.2.
2690 // Check map <3 items> std::map<QString, QPointer<QObject>>.
2691 // Check map.0 std::pair<QString const, QPointer<QObject>>.
2692 // Check map.0.first "." QString.
2693 // CheckType map.0.second QPointer<QObject>.
2694 // Check map.2 std::pair<QString const, QPointer<QObject>>.
2695 // Check map.2.first "Welt" QString.
2697 dummyStatement(&map);
2702 testStdMapStringFoo();
2703 testStdMapCharStarFoo();
2704 testStdMapUIntUInt();
2705 testStdMapUIntStringList();
2706 testStdMapUIntStringListTypedef();
2707 testStdMapUIntFloat();
2708 testStdMapStringFloat();
2709 testStdMapIntString();
2710 testStdMapStringPointer();
2713 } // namespace stdmap
2718 void testStdUniquePtrInt()
2721 std::unique_ptr<int> p(new int(32));
2723 // Check p 32 std::unique_ptr<int, std::default_delete<int> >.
2729 void testStdUniquePtrFoo()
2732 std::unique_ptr<Foo> p(new Foo);
2734 // Check p 32 std::unique_ptr<Foo, std::default_delete<Foo> >.
2740 void testStdSharedPtrInt()
2743 std::shared_ptr<int> p(new int(32));
2745 // Check p 32 std::shared_ptr<int, std::default_delete<int> >.
2751 void testStdSharedPtrFoo()
2754 std::shared_ptr<Foo> p(new Foo);
2756 // Check p 32 std::shared_ptr<Foo, std::default_delete<int> >.
2764 testStdUniquePtrInt();
2765 testStdUniquePtrFoo();
2766 testStdSharedPtrInt();
2767 testStdSharedPtrFoo();
2770 } // namespace stdptr
2775 void testStdSetInt()
2777 // This is not supposed to work with the compiled dumpers.
2783 // Check set <3 items> std::set<int>
2785 dummyStatement(&set);
2788 void testStdSetString()
2790 std::set<QString> set;
2794 // Check set <1 items> std::set<QString>.
2795 // Check set.0 "22.0" QString.
2797 dummyStatement(&set);
2800 void testStdSetPointer()
2803 std::set<QPointer<QObject> > hash;
2804 QPointer<QObject> ptr(&ob);
2806 // Check hash <0 items> std::set<QPointer<QObject>, std::less<QPointer<QObject>>, std::allocator<QPointer<QObject>>>.
2807 // Check ob "" QObject.
2808 // CheckType ptr QPointer<QObject>.
2810 dummyStatement(&ptr);
2817 testStdSetPointer();
2820 } // namespace stdset
2823 namespace stdstack {
2825 void testStdStack1()
2827 // This does not work with the compiled dumpers.
2828 std::stack<int *> s;
2830 // Check s <0 items> std::stack<int*>.
2834 // Check s <1 items> std::stack<int*>.
2838 // Check s <2 items> std::stack<int*>.
2843 // Check s <3 items> std::stack<int*>.
2844 // CheckType s.0 int.
2845 // Check s.1 0x0 int *.
2846 // CheckType s.2 int.
2850 // Check s <2 items> std::stack<int*>.
2854 // Check s <1 items> std::stack<int*>.
2858 // Check s <0 items> std::stack<int*>.
2863 void testStdStack2()
2867 // Check s <0 items> std::stack<int>.
2871 // Check s <1 items> std::stack<int>.
2876 // Check s <2 items> std::stack<int>.
2883 void testStdStack3()
2885 std::stack<Foo *> s;
2887 // Check s <0 items> std::stack<Foo*>.
2891 // Check s <1 items> std::stack<Foo*>.
2895 // Expand s s.0 s.1.
2896 // Check s <2 items> std::stack<Foo*>.
2897 // CheckType s.0 Foo.
2898 // Check s.0.a 1 int.
2899 // CheckType s.1 Foo.
2900 // Check s.1.a 2 int.
2905 void testStdStack4()
2909 // Check s <0 items> std::stack<Foo>.
2913 // Check s <1 items> std::stack<Foo>.
2917 // Expand s s.0 s.1.
2918 // Check s <2 items> std::stack<Foo>.
2919 // CheckType s.0 Foo.
2920 // Check s.0.a 1 int.
2921 // CheckType s.1 Foo.
2922 // Check s.1.a 2 int.
2935 } // namespace stdstack
2938 namespace stdstring {
2940 void testStdString1()
2945 // Check str "" std::string.
2946 // Check wstr "" std::wstring.
2949 wstr += wchar_t('e');
2951 wstr += wchar_t('e');
2956 wstr += wchar_t('e');
2957 wstr += wchar_t('e');
2960 // Check str "bdebdee" std::string.
2961 // Check wstr "eeee" std::wstring.
2963 dummyStatement(&str, &wstr);
2966 void testStdString2()
2968 std::string str = "foo";
2969 QList<std::string> l;
2971 // Check l <0 items> QList<std::string>.
2972 // Check str "foo" std::string.
2976 // Check l <1 items> QList<std::string>.
2980 // Check l <2 items> QList<std::string>.
2984 // Check l <3 items> QList<std::string>.
2989 // Check l <4 items> QList<std::string>.
2990 // CheckType l.0 std::string.
2991 // CheckType l.3 std::string.
2992 // Check str "foo" std::string.
2994 dummyStatement(&str, &l);
2997 void testStdString3()
2999 std::string str = "foo";
3000 std::vector<std::string> v;
3002 // Check str "foo" std::string.
3003 // Check v <0 items> std::vector<std::string>.
3007 // Check v <1 items> std::vector<std::string>.
3011 // Check v <2 items> std::vector<std::string>.
3015 // Check v <3 items> std::vector<std::string>.
3020 // Check v <4 items> std::vector<std::string>.
3021 // Check v.0 "foo" std::string.
3022 // Check v.3 "foo" std::string.
3024 dummyStatement(&str, &v);
3027 void testStdString()
3034 } // namespace stdstring
3037 namespace stdvector {
3039 void testStdVector1()
3041 std::vector<int *> v;
3043 // Check v <0 items> std::vector<int*>.
3045 v.push_back(new int(1));
3047 // Check v <1 items> std::vector<int*>.
3051 // Check v <2 items> std::vector<int*>.
3053 v.push_back(new int(2));
3056 // Check v <3 items> std::vector<int*>.
3058 // Check v.1 0x0 int *.
3064 void testStdVector2()
3073 // Check v <4 items> std::vector<int>.
3080 void testStdVector3()
3082 std::vector<Foo *> v;
3083 v.push_back(new Foo(1));
3085 v.push_back(new Foo(2));
3087 // Expand v v.0 v.0.x v.2.
3088 // Check v <3 items> std::vector<Foo*>.
3089 // CheckType v.0 Foo.
3090 // Check v.0.a 1 int.
3091 // Check v.1 0x0 Foo *.
3092 // CheckType v.2 Foo.
3093 // Check v.2.a 2 int.
3098 void testStdVector4()
3106 // Expand v v.0 v.0.x.
3107 // Check v <4 items> std::vector<Foo>.
3108 // CheckType v.0 Foo.
3109 // Check v.1.a 2 int.
3110 // CheckType v.3 Foo.
3115 void testStdVectorBool1()
3117 std::vector<bool> v;
3125 // Check v <5 items> std::vector<bool>.
3126 // Check v.0 true bool.
3127 // Check v.1 false bool.
3128 // Check v.2 false bool.
3129 // Check v.3 true bool.
3130 // Check v.4 false bool.
3135 void testStdVectorBool2()
3137 std::vector<bool> v1(65, true);
3138 std::vector<bool> v2(65);
3142 // Check v1 <65 items> std::vector<bool>.
3143 // Check v1.0 true bool.
3144 // Check v1.64 true bool.
3145 // Check v2 <65 items> std::vector<bool>.
3146 // Check v2.0 false bool.
3147 // Check v2.64 false bool.
3149 dummyStatement(&v1, &v2);
3152 void testStdVector6()
3154 std::vector<std::list<int> *> vector;
3155 std::list<int> list;
3156 vector.push_back(new std::list<int>(list));
3157 vector.push_back(0);
3159 vector.push_back(new std::list<int>(list));
3160 vector.push_back(0);
3162 // Expand list vector vector.2.
3163 // Check list <1 items> std::list<int>.
3164 // Check list.0 45 int.
3165 // Check vector <4 items> std::vector<std::list<int>*>.
3166 // Check vector.0 <0 items> std::list<int>.
3167 // Check vector.2 <1 items> std::list<int>.
3168 // Check vector.2.0 45 int.
3169 // Check vector.3 0x0 std::list<int> *.
3171 dummyStatement(&vector, &list);
3174 void testStdVector()
3180 testStdVectorBool1();
3181 testStdVectorBool2();
3185 } // namespace stdvector
3188 namespace stdstream {
3190 void testStdStream()
3192 using namespace std;
3195 // CheckType is std::ifstream.
3197 is.open("/etc/passwd");
3200 bool ok = is.good();
3202 // Check ok true bool.
3204 dummyStatement(&is, &ok);
3207 } // namespace stdstream
3210 namespace itemmodel {
3212 void testItemModel()
3215 //QString *s = static_cast<QString *>(static_cast<void *>(&(v.data_ptr().data.c)));
3216 //QString *t = (QString *)&(v.data_ptr());
3218 QStandardItemModel m;
3219 QStandardItem *i1, *i2, *i11;
3220 m.appendRow(QList<QStandardItem *>()
3221 << (i1 = new QStandardItem("1")) << (new QStandardItem("a")) << (new QStandardItem("a2")));
3222 QModelIndex mi = i1->index();
3223 m.appendRow(QList<QStandardItem *>()
3224 << (i2 = new QStandardItem("2")) << (new QStandardItem("b")));
3225 i1->appendRow(QList<QStandardItem *>()
3226 << (i11 = new QStandardItem("11")) << (new QStandardItem("aa")));
3228 // CheckType i1 QStandardItem.
3229 // CheckType i11 QStandardItem.
3230 // CheckType i2 QStandardItem.
3231 // Check m "" QStandardItemModel.
3232 // Check mi "1" QModelIndex.
3234 dummyStatement(&i1, &mi, &m, &i2, &i11);
3237 } // namespace itemmodel
3242 void testQStackInt()
3249 // Check s <2 items> QStack<int>.
3256 void testQStackBig()
3259 for (int i = 0; i != 10000; ++i)
3263 // Check s <10000 items> QStack<int>.
3265 // Check s.1999 1999 int.
3270 void testQStackFooPointer()
3273 s.append(new Foo(1));
3275 s.append(new Foo(2));
3277 // Expand s s.0 s.2.
3278 // Check s <3 items> QStack<Foo*>.
3279 // CheckType s.0 Foo.
3280 // Check s.0.a 1 int.
3281 // Check s.1 0x0 Foo *.
3282 // CheckType s.2 Foo.
3283 // Check s.2.a 2 int.
3288 void testQStackFoo()
3296 // Expand s s.0 s.3.
3297 // Check s <4 items> QStack<Foo>.
3298 // CheckType s.0 Foo.
3299 // Check s.0.a 1 int.
3300 // CheckType s.3 Foo.
3301 // Check s.3.a 4 int.
3306 void testQStackBool()
3313 // Check s <2 items> QStack<bool>.
3314 // Check s.0 true bool.
3315 // Check s.1 false bool.
3325 testQStackFooPointer();
3329 } // namespace qstack
3336 QUrl url(QString("http://www.nokia.com"));
3338 // Check url "http://www.nokia.com" QUrl.
3340 dummyStatement(&url);
3348 void testQStringQuotes()
3350 QString str1("Hello Qt"); // --> Value: "Hello Qt"
3351 QString str2("Hello\nQt"); // --> Value: ""Hello\nQt"" (double quote not expected)
3352 QString str3("Hello\rQt"); // --> Value: ""HelloQt"" (double quote and missing \r not expected)
3353 QString str4("Hello\tQt"); // --> Value: "Hello\9Qt" (expected \t instead of \9)
3355 // Check str1 "Hello Qt" QString.
3356 // Check str2 "Hello\nQt" QString.
3357 // Check str3 "Hello\rQt" QString.
3358 // Check str4 "Hello\tQt" QString.
3360 dummyStatement(&str1, &str2, &str3, &str4);
3365 QString str = "Hello ";
3370 str += QLatin1Char(0);
3371 str += QLatin1Char(1);
3376 // Check str "Hello big, \t\r\n\000\001 fat World World " QString.
3378 dummyStatement(&str);
3381 void stringRefTest(const QString &refstring)
3383 dummyStatement(&refstring);
3388 QString str = "Hello ";
3393 QString string("String Test");
3394 QString *pstring = new QString("Pointer String Test");
3395 stringRefTest(QString("Ref String Test"));
3400 // CheckType pstring QString.
3401 // Check str "Hello big, fat World " QString.
3402 // Check string "HiDu" QString.
3405 dummyStatement(&str, &string, pstring);
3412 testQStringQuotes();
3415 } // namespace qstring
3418 namespace qstringlist {
3420 void testQStringList()
3430 // Check l <3 items> QStringList.
3431 // Check l.0 " big, " QString.
3432 // Check l.1 " fat " QString.
3433 // Check l.2 " World " QString.
3438 } // namespace qstringlist
3445 const wchar_t *w = L"aöa";
3447 if (sizeof(wchar_t) == 4)
3448 u = QString::fromUcs4((uint *)w);
3450 u = QString::fromUtf16((ushort *)w);
3452 // Check u "aöa" QString.
3453 // CheckType w wchar_t *.
3456 // All: Select UTF-8 in "Change Format for Type" in L&W context menu.
3457 // Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
3458 // Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
3459 dummyStatement(&u, &w);
3462 void testCharPointers()
3464 // These tests should result in properly displayed umlauts in the
3465 // Locals&Watchers view. It is only support on gdb with Python.
3467 const char *s = "aöa";
3468 const char *t = "a\xc3\xb6";
3469 const wchar_t *w = L"aöa";
3471 // CheckType s char *.
3472 // CheckType t char *.
3473 // CheckType w wchar_t *.
3476 // All: Select UTF-8 in "Change Format for Type" in L&W context menu.
3477 // Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
3478 // Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
3480 const unsigned char uu[] = { 'a', 153 /* ö Latin1 */, 'a' };
3481 const unsigned char *u = uu;
3483 // CheckType u unsigned char *.
3484 // CheckType uu unsigned char [3].
3487 // Make sure to undo "Change Format".
3488 dummyStatement(&s, &w, &t, &u);
3491 void testCharArrays()
3493 // These tests should result in properly displayed umlauts in the
3494 // Locals&Watchers view. It is only support on gdb with Python.
3496 const char s[] = "aöa";
3497 const char t[] = "aöax";
3498 const wchar_t w[] = L"aöa";
3500 // CheckType s char [5].
3501 // CheckType t char [6].
3502 // CheckType w wchar_t [4].
3505 // All: Select UTF-8 in "Change Format for Type" in L&W context menu.
3506 // Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
3507 // Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
3509 // Make sure to undo "Change Format".
3510 dummyStatement(&s, &w, &t);
3520 } // namespace formats
3527 //char *argv[] = { "xxx", 0 };
3529 doc.setPlainText("Hallo\nWorld");
3532 // CheckType doc QTextDocument.
3534 tc = doc.find("all");
3536 // Check tc 4 QTextCursor.
3538 int pos = tc.position();
3542 int anc = tc.anchor();
3546 dummyStatement(&pos, &anc);
3554 class Thread : public QThread
3559 void setId(int id) { m_id = id; }
3565 for (int i = 0; i != 1000; ++i) {
3576 // CheckType this qthread::Thread.
3577 // Check this.@1 "This is thread #3" QThread.
3579 dummyStatement(this);
3593 for (int i = 0; i != N; ++i) {
3595 thread[i].setObjectName("This is thread #" + QString::number(i));
3600 // CheckType thread qthread::Thread [14].
3601 // Check thread.0 "This is thread #0" qthread::Thread.
3602 // Check thread.13 "This is thread #13" qthread::Thread.
3604 for (int i = 0; i != N; ++i) {
3607 dummyStatement(&thread);
3612 Q_DECLARE_METATYPE(QHostAddress)
3613 Q_DECLARE_METATYPE(QList<int>)
3614 Q_DECLARE_METATYPE(QStringList)
3616 Q_DECLARE_METATYPE(QMap<uint COMMA QStringList>)
3618 namespace qvariant {
3620 void testQVariant1()
3623 QVariant::Type t = QVariant::String;
3624 value = QVariant(t, (void*)0);
3625 *(QString*)value.data() = QString("Some string");
3628 // Check t QVariant::String (10) QVariant::Type.
3629 // Check value "Some string" QVariant (QString).
3632 // Check the variant contains a proper QString.
3636 void testQVariant2()
3638 // Check var contains objects of the types indicated.
3640 QVariant var; // Type 0, invalid
3642 // Check var (invalid) QVariant (invalid).
3644 var.setValue(true); // 1, bool
3646 // Check var true QVariant (bool).
3648 var.setValue(2); // 2, int
3650 // Check var 2 QVariant (int).
3652 var.setValue(3u); // 3, uint
3654 // Check var 3 QVariant (uint).
3656 var.setValue(qlonglong(4)); // 4, qlonglong
3658 // Check var 4 QVariant (qlonglong).
3660 var.setValue(qulonglong(5)); // 5, qulonglong
3662 // Check var 5 QVariant (qulonglong).
3664 var.setValue(double(6)); // 6, double
3666 // Check var 6 QVariant (double).
3668 var.setValue(QChar(7)); // 7, QChar
3670 // Check var '?' (7) QVariant (QChar).
3672 //None, # 8, QVariantMap
3673 // None, # 9, QVariantList
3674 var.setValue(QString("Hello 10")); // 10, QString
3676 // Check var "Hello 10" QVariant (QString).
3678 var.setValue(QRect(100, 200, 300, 400)); // 19 QRect
3680 // Check var 300x400+100+200 QVariant (QRect).
3682 var.setValue(QRectF(100, 200, 300, 400)); // 19 QRectF
3684 // Check var 300x400+100+200 QVariant (QRectF).
3706 dummyStatement(&var);
3709 void testQVariant3()
3713 // Check var (invalid) QVariant (invalid).
3716 // Check the list is updated properly.
3717 var.setValue(QStringList() << "World");
3720 // Check var <1 items> QVariant (QStringList).
3721 // Check var.0 "World" QString.
3723 var.setValue(QStringList() << "World" << "Hello");
3726 // Check var <2 items> QVariant (QStringList).
3727 // Check var.1 "Hello" QString.
3729 var.setValue(QStringList() << "Hello" << "Hello");
3732 // Check var <2 items> QVariant (QStringList).
3733 // Check var.0 "Hello" QString.
3734 // Check var.1 "Hello" QString.
3736 var.setValue(QStringList() << "World" << "Hello" << "Hello");
3739 // Check var <3 items> QVariant (QStringList).
3740 // Check var.0 "World" QString.
3742 dummyStatement(&var);
3745 void testQVariant4()
3748 QHostAddress ha("127.0.0.1");
3750 QHostAddress ha1 = var.value<QHostAddress>();
3752 // Expand ha ha1 var.
3753 // Check ha "127.0.0.1" QHostAddress.
3754 // Check ha.a 0 quint32.
3755 // CheckType ha.a6 Q_IPV6ADDR.
3756 // Check ha.ipString "127.0.0.1" QString.
3757 // Check ha.isParsed false bool.
3758 // Check ha.protocol QAbstractSocket::UnknownNetworkLayerProtocol (-1) QAbstractSocket::NetworkLayerProtocol.
3759 // Check ha.scopeId "" QString.
3760 // Check ha1 "127.0.0.1" QHostAddress.
3761 // Check ha1.a 0 quint32.
3762 // CheckType ha1.a6 Q_IPV6ADDR.
3763 // Check ha1.ipString "127.0.0.1" QString.
3764 // Check ha1.isParsed false bool.
3765 // Check ha1.protocol QAbstractSocket::UnknownNetworkLayerProtocol (-1) QAbstractSocket::NetworkLayerProtocol.
3766 // Check ha1.scopeId "" QString.
3767 // CheckType var QVariant (QHostAddress).
3768 // Check var.data "127.0.0.1" QHostAddress.
3770 dummyStatement(&ha1);
3773 void testQVariant5()
3775 // This checks user defined types in QVariants.
3776 typedef QMap<uint, QStringList> MyType;
3778 my[1] = (QStringList() << "Hello");
3779 my[3] = (QStringList() << "World");
3782 // FIXME: Known to break
3783 //QString type = var.typeName();
3786 // Expand my my.0 my.0.value my.1 my.1.value var var.data var.data.0 var.data.0.value var.data.1 var.data.1.value.
3787 // Check my <2 items> qvariant::MyType.
3788 // Check my.0 QMapNode<unsigned int, QStringList>.
3789 // Check my.0.key 1 unsigned int.
3790 // Check my.0.value <1 items> QStringList.
3791 // Check my.0.value.0 "Hello" QString.
3792 // Check my.1 QMapNode<unsigned int, QStringList>.
3793 // Check my.1.key 3 unsigned int.
3794 // Check my.1.value <1 items> QStringList.
3795 // Check my.1.value.0 "World" QString.
3796 // CheckType var QVariant (QMap<unsigned int , QStringList>).
3797 // Check var.data <2 items> QMap<unsigned int, QStringList>.
3798 // Check var.data.0 QMapNode<unsigned int, QStringList>.
3799 // Check var.data.0.key 1 unsigned int.
3800 // Check var.data.0.value <1 items> QStringList.
3801 // Check var.0.value.0 "Hello" QString.
3802 // Check var.data.1 QMapNode<unsigned int, QStringList>.
3803 // Check var.data.1.key 3 unsigned int.
3804 // Check var.data.1.value <1 items> QStringList.
3805 // Check var.data.1.value.0 "World" QString.
3810 dummyStatement(&var);
3813 void testQVariant6()
3816 list << 1 << 2 << 3;
3817 QVariant variant = qVariantFromValue(list);
3819 // Expand list variant variant.data.
3820 // Check list <3 items> QList<int>.
3821 // Check list.0 1 int.
3822 // Check list.1 2 int.
3823 // Check list.2 3 int.
3824 // CheckType variant QVariant (QList<int>).
3825 // Check variant.data <3 items> QList<int>.
3826 // Check variant.data.0 1 int.
3827 // Check variant.data.1 2 int.
3828 // Check variant.data.2 3 int.
3831 list = qVariantValue<QList<int> >(variant);
3834 // Check list <3 items> QList<int>.
3835 // Check list.0 1 int.
3836 // Check list.1 2 int.
3837 // Check list.2 3 int.
3839 dummyStatement(&list);
3842 void testQVariantList()
3846 // Check vl <0 items> QVariantList.
3848 vl.append(QVariant(1));
3849 vl.append(QVariant(2));
3850 vl.append(QVariant("Some String"));
3851 vl.append(QVariant(21));
3852 vl.append(QVariant(22));
3853 vl.append(QVariant("2Some String"));
3856 // Check vl <6 items> QVariantList.
3857 // CheckType vl.0 QVariant (int).
3858 // CheckType vl.2 QVariant (QString).
3860 dummyStatement(&vl);
3863 void testQVariantMap()
3867 // Check vm <0 items> QVariantMap.
3869 vm["a"] = QVariant(1);
3870 vm["b"] = QVariant(2);
3871 vm["c"] = QVariant("Some String");
3872 vm["d"] = QVariant(21);
3873 vm["e"] = QVariant(22);
3874 vm["f"] = QVariant("2Some String");
3876 // Expand vm vm.0 vm.5.
3877 // Check vm <6 items> QVariantMap.
3878 // Check vm.0 QMapNode<QString, QVariant>.
3879 // Check vm.0.key "a" QString.
3880 // Check vm.0.value 1 QVariant (int).
3881 // Check vm.5 QMapNode<QString, QVariant>.
3882 // Check vm.5.key "f" QString.
3883 // Check vm.5.value "2Some String" QVariant (QString).
3885 dummyStatement(&vm);
3900 } // namespace qvariant
3905 void testQVectorIntBig()
3907 // This tests the display of a big vector.
3908 QVector<int> vec(10000);
3911 // Check vec <10000 items> QVector<int>.
3912 // Check vec.0 0 int.
3913 // Check vec.1999 0 int.
3917 // check that the display updates in reasonable time
3924 // Check vec <10002 items> QVector<int>.
3925 // Check vec.1 1 int.
3926 // Check vec.2 2 int.
3928 dummyStatement(&vec);
3931 void testQVectorFoo()
3933 // This tests the display of a vector of pointers to custom structs.
3936 // Check vec <0 items> QVector<Foo>.
3938 // step over, check display.
3942 // Expand vec vec.0 vec.1.
3943 // Check vec <2 items> QVector<Foo>.
3944 // CheckType vec.0 Foo.
3945 // Check vec.0.a 1 int.
3946 // CheckType vec.1 Foo.
3947 // Check vec.1.a 2 int.
3949 dummyStatement(&vec);
3952 typedef QVector<Foo> FooVector;
3954 void testQVectorFooTypedef()
3959 dummyStatement(&vec);
3962 void testQVectorFooStar()
3964 // This tests the display of a vector of pointers to custom structs.
3967 // Check vec <0 items> QVector<Foo*>.
3970 // check that the display is ok.
3971 vec.append(new Foo(1));
3973 vec.append(new Foo(2));
3974 // switch "Auto derefencing pointers" in Locals context menu
3975 // off and on again, and check result looks sane.
3977 // Expand vec vec.0 vec.2.
3978 // Check vec <3 items> QVector<Foo*>.
3979 // CheckType vec.0 Foo.
3980 // Check vec.0.a 1 int.
3981 // Check vec.1 0x0 Foo *.
3982 // CheckType vec.2 Foo.
3983 // Check vec.2.a 2 int.
3985 dummyStatement(&vec);
3988 void testQVectorBool()
3990 // This tests the display of a vector of custom structs.
3993 // Check vec <0 items> QVector<bool>.
3996 // check that the display is ok.
4001 // Check vec <2 items> QVector<bool>.
4002 // Check vec.0 true bool.
4003 // Check vec.1 false bool.
4005 dummyStatement(&vec);
4008 void testQVectorListInt()
4010 QVector<QList<int> > vec;
4011 QVector<QList<int> > *pv = &vec;
4013 // CheckType pv QVector<QList<int>>.
4014 // Check vec <0 items> QVector<QList<int>>.
4016 vec.append(QList<int>() << 1);
4017 vec.append(QList<int>() << 2 << 3);
4019 // Expand pv pv.0 pv.1 vec vec.0 vec.1.
4020 // CheckType pv QVector<QList<int>>.
4021 // Check pv.0 <1 items> QList<int>.
4022 // Check pv.0.0 1 int.
4023 // Check pv.1 <2 items> QList<int>.
4024 // Check pv.1.0 2 int.
4025 // Check pv.1.1 3 int.
4026 // Check vec <2 items> QVector<QList<int>>.
4027 // Check vec.0 <1 items> QList<int>.
4028 // Check vec.0.0 1 int.
4029 // Check vec.1 <2 items> QList<int>.
4030 // Check vec.1.0 2 int.
4031 // Check vec.1.1 3 int.
4033 dummyStatement(pv, &vec);
4038 testQVectorIntBig();
4040 testQVectorFooTypedef();
4041 testQVectorFooStar();
4043 testQVectorListInt();
4046 } // namespace qvector
4054 Goo(const QString &str, const int n) : str_(str), n_(n) {}
4060 typedef QList<Goo> GooList;
4062 void testNoArgumentName(int i, int, int k)
4064 // This is not supposed to work with the compiled dumpers.
4066 list.append(Goo("Hello", 1));
4067 list.append(Goo("World", 2));
4070 list2.append(Goo("Hello", 1));
4071 list2.append(Goo("World", 2));
4074 // Expand list list.0 list.1 list2 list2.1.
4077 // Check list <2 items> noargs::GooList.
4078 // CheckType list.0 noargs::Goo.
4079 // Check list.0.n_ 1 int.
4080 // Check list.0.str_ "Hello" QString.
4081 // CheckType list.1 noargs::Goo.
4082 // Check list.1.n_ 2 int.
4083 // Check list.1.str_ "World" QString.
4084 // Check list2 <2 items> QList<noargs::Goo>.
4085 // CheckType list2.0 noargs::Goo.
4086 // Check list2.0.n_ 1 int.
4087 // Check list2.0.str_ "Hello" QString.
4088 // CheckType list2.1 noargs::Goo.
4089 // Check list2.1.n_ 2 int.
4090 // Check list2.1.str_ "World" QString.
4092 dummyStatement(&i, &k);
4095 } // namespace noargs
4100 void foo(QList<int>) {}
4101 void foo(QList<QVector<int> >) {}
4102 void foo(QList<QVector<int> *>) {}
4103 void foo(QList<QVector<int *> *>) {}
4106 void foo(QList<QVector<T> *>) {}
4111 class MyBase : public QObject
4115 virtual void doit(int i)
4125 class MyFoo : public MyBase
4129 virtual void doit(int i)
4131 // Note there's a local 'n' and one in the base class.
4138 class MyBar : public MyFoo
4141 virtual void doit(int i)
4149 class MyAnon : public MyBar
4152 virtual void doit(int i)
4160 class MyBaz : public MyAnon
4163 virtual void doit(int i)
4173 } // namespace nested
4175 void testNamespace()
4177 // This checks whether classes with "special" names are
4178 // properly displayed.
4179 using namespace nested;
4185 // CheckType anon namespc::nested::(anonymous namespace)::MyAnon.
4186 // CheckType bar namespc::nested::MyBar.
4187 // CheckType baz namespc::nested::(anonymous namespace)::baz::MyBaz.
4188 // CheckType foo namespc::nested::MyFoo.
4190 // step into the doit() functions
4198 } // namespace namespc
4202 class Z : public QObject
4216 void testMemoryView()
4219 for (int i = 0; i != 20; ++i)
4232 // This tests display of basic types.
4237 for (int i = 0; i != 3; ++i)
4238 for (int j = 0; j != 3; ++j)
4242 // CheckType d double [3][3].
4243 // CheckType d.0 double [3].
4244 // Check d.0.0 0 double.
4245 // Check d.0.2 2 double.
4246 // CheckType d.2 double [3].
4260 // CheckType c char [20].
4261 // Check c.0 97 'a' char.
4262 // Check c.3 100 'd' char.
4276 // CheckType s QString [20].
4277 // Check s.0 "a" QString.
4278 // Check s.3 "d" QString.
4279 // Check s.4 "" QString.
4280 // Check s.19 "" QString.
4294 // CheckType b QByteArray [20].
4295 // Check b.0 "a" QByteArray.
4296 // Check b.3 "d" QByteArray.
4297 // Check b.4 "" QByteArray.
4298 // Check b.19 "" QByteArray.
4306 //for (int i = 0; i != sizeof(foo)/sizeof(foo[0]); ++i) {
4307 for (int i = 0; i < 5; ++i) {
4313 // CheckType foo Foo [10].
4314 // CheckType foo.0 Foo.
4315 // CheckType foo.9 Foo.
4317 dummyStatement(&foo);
4320 // https://bugreports.qt-project.org/browse/QTCREATORBUG-5326
4328 // CheckType s char [6].
4329 // Check s.0 0 '\0' char.
4332 // Manual: Open pinnable tooltip.
4333 // Manual: Step over.
4334 // Manual: Check that display and tooltip look sane.
4340 // Manual: Close tooltip.
4344 static char buf[20] = { 0 };
4351 // CheckType s char *.
4354 // Manual: Open pinnable tooltip.
4355 // Manual: Step over.
4356 // Manual: Check that display and tooltip look sane.
4378 void testBitfields()
4380 // This checks whether bitfields are properly displayed
4384 // CheckType s basic::S.
4385 // CheckType s.b bool.
4386 // CheckType s.c bool.
4387 // CheckType s.d double.
4388 // CheckType s.f float.
4389 // CheckType s.i int.
4390 // CheckType s.q qreal.
4391 // CheckType s.x uint.
4392 // CheckType s.y uint.
4400 Function(QByteArray var, QByteArray f, double min, double max)
4401 : var(var), f(f), min(min), max(max) {}
4410 // In order to use this, switch on the 'qDump__Function' in dumper.py
4411 Function func("x", "sin(x)", 0, 1);
4414 // CheckType func basic::Function.
4415 // Check func.f "sin(x)" QByteArray.
4416 // Check func.max 1 double.
4417 // Check func.min 0 double.
4418 // Check func.var "x" QByteArray.
4428 // CheckType func basic::Function.
4429 // Check func.f "cos(x)" QByteArray.
4430 // Check func.max 7 double.
4432 dummyStatement(&func);
4438 Color() { r = 1, g = 2, b = 3, a = 4; }
4441 void testAlphabeticSorting()
4443 // This checks whether alphabetic sorting of structure
4448 // CheckType c basic::Color.
4455 // Manual: Toogle "Sort Member Alphabetically" in context menu
4456 // Manual: of "Locals and Expressions" view.
4457 // Manual: Check that order of displayed members changes.
4462 typedef unsigned long long vl;
4463 typedef vl verylong;
4468 typedef quint32 myType1;
4469 typedef unsigned int myType2;
4473 ns::verylong k = 1000;
4475 // Check j 1000 basic::ns::vl.
4476 // Check k 1000 basic::ns::verylong.
4477 // Check t1 0 basic::myType1.
4478 // Check t2 0 basic::myType2.
4480 dummyStatement(&j, &k, &t1, &t2);
4507 // CheckType u basic::U.
4508 // CheckType u.a int.
4509 // CheckType u.b int.
4514 void testUninitialized()
4516 // This tests the display of uninitialized data.
4518 BREAK_UNINITIALIZED_HERE;
4519 // Check hii <not accessible> QHash<int, int>.
4520 // Check hss <not accessible> QHash<QString, QString>.
4521 // Check li <not accessible> QList<int>.
4522 // CheckType mii <not accessible> QMap<int, int>.
4523 // Check mss <not accessible> QMap<QString, QString>.
4524 // Check s <not accessible> QString.
4525 // Check si <not accessible> QStack<int>.
4526 // Check sl <not accessible> QStringList.
4527 // Check sli <not accessible> std::list<int>.
4528 // CheckType smii std::map<int, int>.
4529 // CheckType smss std::map<std::string, std::string>.
4530 // CheckType ss std::string.
4531 // Check ssi <not accessible> std::stack<int>.
4532 // Check ssl <not accessible> std::list<std::string>.
4533 // CheckType svi std::vector<int>.
4534 // Check vi <not accessible> QVector<int>.
4537 // Manual: Note: All values should be <uninitialized> or random data.
4538 // Manual: Check that nothing bad happens if items with random data
4539 // Manual: are expanded.
4543 QMap<QString, QString> mss;
4544 QHash<int, int> hii;
4545 QHash<QString, QString> hss;
4551 std::map<int, int> smii;
4552 std::map<std::string, std::string> smss;
4554 std::list<std::string> ssl;
4555 std::vector<int> svi;
4556 std::stack<int> ssi;
4558 dummyStatement(&s, &sl, &mii, &mss, &hii, &hss, &si, &vi, &li,
4559 &ss, &smii, &smss, &sli, &svi, &ssi, &ssl);
4562 void testTypeFormats()
4564 // These tests should result in properly displayed umlauts in the
4565 // Locals and Expressions view. It is only support on gdb with Python.
4567 const char *s = "aöa";
4568 const wchar_t *w = L"aöa";
4572 // CheckType s char *.
4573 // Skip Check s.*s 97 'a' char.
4574 // Check u "" QString.
4575 // CheckType w wchar_t *.
4578 // All: Select UTF-8 in "Change Format for Type" in L&W context menu.
4579 // Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
4580 // Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
4582 if (sizeof(wchar_t) == 4)
4583 u = QString::fromUcs4((uint *)w);
4585 u = QString::fromUtf16((ushort *)w);
4587 // Make sure to undo "Change Format".
4588 dummyStatement(s, w);
4591 typedef void *VoidPtr;
4592 typedef const void *CVoidPtr;
4598 void doSomething(CVoidPtr cp) const;
4601 void A::doSomething(CVoidPtr cp) const
4604 // CheckType cp basic::CVoidPtr.
4606 dummyStatement(&cp);
4621 void testPointerTypedef()
4627 // CheckType a basic::A.
4628 // CheckType cp basic::CVoidPtr.
4629 // CheckType p basic::VoidPtr.
4632 dummyStatement(&a, &p);
4635 void testStringWithNewline()
4637 QString hallo = "hallo\nwelt";
4639 // Check hallo "hallo\nwelt" QString.
4642 // Check that string is properly displayed.
4643 dummyStatement(&hallo);
4646 void testMemoryView()
4650 // CheckType a int [20].
4653 // Select "Open Memory View" from Locals and Expressions
4654 // context menu for item 'a'.
4655 // Step several times.
4656 // Check the contents of the memory view updates.
4657 for (int i = 0; i != 20; ++i)
4662 void testColoredMemoryView()
4668 // Check d 23 double.
4670 // Check s "Foo" QString.
4673 // Select "Open Memory View" from Locals and Expressions
4674 // context menu for item 'd'.
4675 // Check that the opened memory view contains coloured items
4676 // for 'i', 'd', and 's'.
4677 dummyStatement(&i, &d, &s);
4680 void testReference1()
4691 // Check d 43 basic::Ref.
4693 dummyStatement(&a, &b, &c, &d);
4696 void testReference2()
4698 QString a = "hello";
4699 const QString &b = fooxx();
4700 typedef QString &Ref;
4701 const QString c = "world";
4704 // Check a "hello" QString.
4705 // Check b "bababa" QString.
4706 // Check c "world" QString.
4707 // Check d "hello" basic::Ref.
4709 dummyStatement(&a, &b, &c, &d);
4712 void testReference3(const QString &a)
4714 const QString &b = a;
4715 typedef QString &Ref;
4716 const Ref d = const_cast<Ref>(a);
4718 // Check a "hello" QString.
4719 // Check b "hello" QString.
4720 // Check d "hello" basic::Ref.
4722 dummyStatement(&a, &b, &d);
4725 void testLongEvaluation1()
4727 QDateTime time = QDateTime::currentDateTime();
4728 const int N = 10000;
4730 for (int i = 0; i < 10000; ++i) {
4732 time = time.addDays(1);
4736 // Check N 10000 int.
4737 // CheckType bigv QDateTime [10000].
4738 // CheckType bigv.0 QDateTime.
4739 // CheckType bigv.9999 QDateTime.
4740 // CheckType time QDateTime.
4742 // Note: This is expected to _not_ take up to a minute.
4743 dummyStatement(&bigv);
4746 void testLongEvaluation2()
4748 const int N = 10000;
4750 for (int i = 0; i < 10000; ++i)
4754 // Check N 10000 int.
4755 // CheckType bigv int [10000].
4756 // Check bigv.0 0 int.
4757 // Check bigv.9999 9999 int.
4759 // Note: This is expected to take up to a minute.
4760 dummyStatement(&bigv);
4766 proc.start("/bin/ls");
4767 proc.waitForFinished();
4768 QByteArray ba = proc.readAllStandardError();
4771 // Check ba "x" QByteArray.
4772 // Check proc "" QProcess.
4775 // Check there is some contents in ba. Error message is expected.
4776 dummyStatement(&ba);
4779 void testFunctionPointerHelper() {}
4781 void testFunctionPointer()
4783 typedef void (*func_t)();
4784 func_t f2 = testFunctionPointerHelper;
4786 // CheckType f2 basic::func_t.
4789 // Check there's a valid display for f2.
4790 dummyStatement(&f2);
4793 void testPassByReferenceHelper(Foo &f)
4798 // Check f.a 12 int.
4804 // Check f.a 13 int.
4808 void testPassByReference()
4811 testPassByReferenceHelper(f);
4817 qint64 a = Q_INT64_C(0xF020304050607080);
4818 quint64 b = Q_UINT64_C(0xF020304050607080);
4819 quint64 c = std::numeric_limits<quint64>::max() - quint64(1);
4821 // Check a -1143861252567568256 qint64.
4822 // Check b -1143861252567568256 quint64.
4823 // Check c -2 quint64.
4825 dummyStatement(&a, &b, &c);
4842 // Check n "2" QString.
4847 // Check n "3" QString.
4853 // Check n 3.5 double.
4854 // Check n@1 "3" QString.
4859 // Check n 4.5 double.
4860 // Check n@1 "3" QString.
4866 // Check n "3" QString.
4872 // Check n "4" QString.
4886 bool testReturnBool()
4891 QString testReturnQString()
4898 bool b = testReturnBool();
4900 // Check b true bool.
4902 int i = testReturnInt();
4906 QString s = testReturnQString();
4908 // Check s "string" QString.
4910 dummyStatement(&i, &b, &s);
4917 testReference3("hello");
4928 testAlphabeticSorting();
4931 testPointerTypedef();
4934 testUninitialized();
4936 testStringWithNewline();
4938 testColoredMemoryView();
4939 testLongEvaluation1();
4940 testLongEvaluation2();
4942 testFunctionPointer();
4943 testPassByReference();
4948 } // namespace basic
4955 using namespace std;
4956 wstring x = L"xxxxx";
4957 wstring::iterator i = x.begin();
4960 while (i != x.end()) {
4966 string::iterator j = y.begin();
4967 while (j != y.end()) {
4976 // Mixing cout and wcout does not work with gcc.
4977 // See http://gcc.gnu.org/ml/gcc-bugs/2006-05/msg01193.html
4978 // which also says "you can obtain something close to your
4979 // expectations by calling std::ios::sync_with_stdio(false);
4980 // at the beginning of your program."
4982 using namespace std;
4983 //std::ios::sync_with_stdio(false);
4986 wcout << L"WWWWWW" << endl;
4987 wcerr << L"YYYYYY" << endl;
4988 cout << "CCCCCC" << endl;
4989 cerr << "EEEEEE" << endl;
4990 wcout << L"WWWWWW" << endl;
4991 wcerr << L"YYYYYY" << endl;
4992 cout << "CCCCCC" << endl;
4993 cerr << "EEEEEE" << endl;
4994 wcout << L"WWWWWW" << endl;
4995 wcerr << L"YYYYYY" << endl;
4996 cout << "CCCCCC" << endl;
4997 cerr << "EEEEEE" << endl;
5002 qDebug() << "qDebug() 1";
5003 qDebug() << "qDebug() 2";
5004 qDebug() << "qDebug() 3";
5005 qDebug() << "qDebug <foo & bar>";
5007 std::cout << "std::cout @@ 1" << std::endl;
5008 std::cout << "std::cout @@ 2\n";
5009 std::cout << "std::cout @@ 3" << std::endl;
5010 std::cout << "std::cout <foo & bar>\n";
5012 std::cerr << "std::cerr 1\n";
5013 std::cerr << "std::cerr 2\n";
5014 std::cerr << "std::cerr 3\n";
5015 std::cerr << "std::cerr <foo & bar>\n";
5020 // This works only when "Run in terminal" is selected
5021 // in the Run Configuration.
5047 for (i = 0; i < 4; i++) {
5052 sseA = _mm_loadu_ps(a);
5053 sseB = _mm_loadu_ps(b);
5056 // CheckType sseA __m128.
5057 // CheckType sseB __m128.
5059 dummyStatement(&i, &sseA, &sseB);
5071 BREAK_UNINITIALIZED_HERE;
5072 QScriptEngine engine;
5073 QDateTime date = QDateTime::currentDateTime();
5077 // Check engine "" QScriptEngine.
5078 // Check s (invalid) QScriptValue.
5079 // Check x1 <not accessible> QString.
5081 s = QScriptValue(33);
5082 int x = s.toInt32();
5084 s = QScriptValue(QString("34"));
5085 QString x1 = s.toString();
5087 s = engine.newVariant(QVariant(43));
5088 QVariant v = s.toVariant();
5090 s = engine.newVariant(QVariant(43.0));
5091 s = engine.newVariant(QVariant(QString("sss")));
5092 s = engine.newDate(date);
5093 date = s.toDateTime();
5094 s.setProperty("a", QScriptValue());
5095 QScriptValue d = s.data();
5097 // Check d (invalid) QScriptValue.
5098 // Check v 43 QVariant (int).
5100 // Check x1 "34" QString.
5102 dummyStatement(&x1, &v, &s, &d, &x);
5108 } // namespace script
5114 void testBoostOptional1()
5116 boost::optional<int> i;
5118 // Check i <uninitialized> boost::optional<int>.
5122 // Check i 1 boost::optional<int>.
5127 void testBoostOptional2()
5129 boost::optional<QStringList> sl;
5131 // Check sl <uninitialized> boost::optional<QStringList>.
5133 sl = (QStringList() << "xxx" << "yyy");
5134 sl.get().append("zzz");
5136 // Check sl <3 items> boost::optional<QStringList>.
5138 dummyStatement(&sl);
5141 void testBoostSharedPtr()
5143 boost::shared_ptr<int> s;
5144 boost::shared_ptr<int> i(new int(43));
5145 boost::shared_ptr<int> j = i;
5146 boost::shared_ptr<QStringList> sl(new QStringList(QStringList() << "HUH!"));
5148 // Check s boost::shared_ptr<int>.
5149 // Check i 43 boost::shared_ptr<int>.
5150 // Check j 43 boost::shared_ptr<int>.
5151 // Check sl <1 item> boost::shared_ptr<QStringList>.
5153 dummyStatement(&s, &j, &sl);
5156 void testBoostGregorianDate()
5158 using namespace boost;
5159 using namespace gregorian;
5160 date d(2005, Nov, 29);
5162 // Check d Tue Nov 29 2005 boost::gregorian::date.
5167 // Check d Thu Dec 29 2005 boost::gregorian::date.
5172 // Check d Sun Jan 29 2006 boost::gregorian::date.
5175 // snap-to-end-of-month behavior kicks in:
5178 // Check d Tue Feb 28 2006 boost::gregorian::date.
5181 // Also end of the month (expected in boost)
5184 // Check d Fri Mar 31 2006 boost::gregorian::date.
5187 // Not where we started (expected in boost)
5190 // Check d Tue Nov 30 2005 boost::gregorian::date.
5196 void testBoostPosixTimeTimeDuration()
5198 using namespace boost;
5199 using namespace posix_time;
5200 time_duration d1(1, 0, 0);
5202 // Check d1 01:00:00 boost::posix_time::time_duration.
5204 time_duration d2(0, 1, 0);
5206 // Check d2 00:01:00 boost::posix_time::time_duration.
5208 time_duration d3(0, 0, 1);
5210 // Check d3 00:00:01 boost::posix_time::time_duration.
5212 dummyStatement(&d1, &d2, &d3);
5215 void testBoostPosixTimePtime()
5217 using namespace boost;
5218 using namespace gregorian;
5219 using namespace posix_time;
5220 ptime p1(date(2002, 1, 10), time_duration(1, 0, 0));
5222 // Check p1 Thu Jan 10 01:00:00 2002 boost::posix_time::ptime.
5224 ptime p2(date(2002, 1, 10), time_duration(0, 0, 0));
5226 // Check p2 Thu Jan 10 00:00:00 2002 boost::posix_time::ptime.
5228 ptime p3(date(1970, 1, 1), time_duration(0, 0, 0));
5230 // Check p3 Thu Jan 1 00:00:00 1970 boost::posix_time::ptime.
5232 dummyStatement(&p1, &p2, &p3);
5237 testBoostOptional1();
5238 testBoostOptional2();
5239 testBoostSharedPtr();
5240 testBoostPosixTimeTimeDuration();
5241 testBoostPosixTimePtime();
5242 testBoostGregorianDate();
5251 } // namespace boost
5263 enum type_t { MPI_LB, MPI_INT, MPI_CHAR, MPI_DOUBLE, MPI_UB };
5268 tree_entry(int l, int o, type_t t)
5269 : blocklength(l), offset(o), type(t)
5279 enum kind_t { STRUCT };
5284 tree_entry entries[20];
5289 structdata buffer = {
5291 {0, 1024, 2048, 3072, 4096, 5120, 6144 },
5292 {"message to 1 of 2: hello"},
5293 {0, 3.14, 6.2831853071795862, 9.4247779607693793, 13},
5299 x.kind = tree::STRUCT;
5301 x.entries[0] = tree_entry(1, -4, MPI_LB);
5302 x.entries[1] = tree_entry(5, 0, MPI_INT);
5303 x.entries[2] = tree_entry(7, 47, MPI_CHAR);
5304 x.entries[3] = tree_entry(2, 76, MPI_DOUBLE);
5305 x.entries[4] = tree_entry(1, 100, MPI_UB);
5349 // FIXME: put in namespace kr, adjust qdump__KRBase in dumpers/qttypes.py
5352 enum Type { TYPE_A, TYPE_B } type;
5353 KRBase(Type _type) : type(_type) {}
5356 struct KRA : KRBase { int x; int y; KRA():KRBase(TYPE_A), x(1), y(32) {} };
5357 struct KRB : KRBase { KRB():KRBase(TYPE_B) {} };
5364 // Only with python.
5365 // This tests qdump__KRBase in dumpers/qttypes.py which uses
5366 // a static typeflag to dispatch to subclasses.
5370 KRBase *ptr1 = new KRA;
5371 KRBase *ptr2 = new KRB;
5374 // Expand ptr1 ptr2.
5375 // CheckType ptr1 KRBase.
5376 // Check ptr1.type KRBase::TYPE_A (0) KRBase::Type.
5377 // CheckType ptr2 KRBase.
5378 // Check ptr2.type KRBase::TYPE_B (1) KRBase::Type.
5380 dummyStatement(&ptr1, &ptr2);
5391 using namespace Eigen;
5393 Vector3d test = Vector3d::Zero();
5395 Matrix3d myMatrix = Matrix3d::Constant(5);
5396 MatrixXd myDynamicMatrix(30, 10);
5398 myDynamicMatrix(0, 0) = 0;
5399 myDynamicMatrix(1, 0) = 1;
5400 myDynamicMatrix(2, 0) = 2;
5402 Matrix<double, 12, 15, ColMajor> colMajorMatrix;
5403 Matrix<double, 12, 15, RowMajor> rowMajorMatrix;
5406 for (int i = 0; i != 12; ++i) {
5407 for (int j = 0; j != 15; ++j) {
5408 colMajorMatrix(i, j) = k;
5409 rowMajorMatrix(i, j) = k;
5417 dummyStatement(&colMajorMatrix, &rowMajorMatrix, &test,
5418 &myMatrix, &myDynamicMatrix);
5428 // https://bugreports.qt-project.org/browse/QTCREATORBUG-842
5432 // Manual: Check that Application Output pane contains string "Test".
5436 } // namespace bug842
5443 // https://bugreports.qt-project.org/browse/QTCREATORBUG-3611
5444 typedef unsigned char byte;
5448 // Check f 50 bug3611::byte.
5455 // Check f 53 bug3611::byte.
5457 dummyStatement(&f, &x);
5460 } // namespace bug3611
5465 // https://bugreports.qt-project.org/browse/QTCREATORBUG-4019
5470 A4019() : test(7) {}
5472 void doSomething() const;
5475 void A4019::doSomething() const
5477 std::cout << test << std::endl;
5486 } // namespave bug4019
5491 // https://bugreports.qt-project.org/browse/QTCREATORBUG-4997
5495 using namespace std;
5496 // cin.get(); // if commented out, the debugger doesn't stop at the breakpoint
5497 // in the next line on Windows when "Run in Terminal" is used.^
5505 // https://bugreports.qt-project.org/browse/QTCREATORBUG-4904
5507 struct CustomStruct {
5514 QMap<int, CustomStruct> map;
5518 CustomStruct cs2 = cs1;
5520 map.insert(cs1.id, cs1);
5521 map.insert(cs2.id, cs2);
5522 QMap<int, CustomStruct>::iterator it = map.begin();
5524 // Expand map map.0 map.0.value.
5525 // Check map <2 items> QMap<int, bug4904::CustomStruct>.
5526 // Check map.0 QMapNode<int, bug4904::CustomStruct>.
5527 // Check map.0.key -1 int.
5528 // CheckType map.0.value bug4904::CustomStruct.
5529 // Check map.0.value.dvalue 3.1400000000000001 double.
5530 // Check map.0.value.id -1 int.
5532 dummyStatement(&it);
5535 } // namespace bug4904
5540 // https://bugreports.qt-project.org/browse/QTCREATORBUG-5046
5542 struct Foo { int a, b, c; };
5553 // CheckType f bug5046::Foo.
5559 // Manual: pop up main editor tooltip over 'f'
5560 // Manual: verify that the entry is expandable, and expansion works
5564 } // namespace bug5046
5569 // https://bugreports.qt-project.org/browse/QTCREATORBUG-5106
5574 A5106(int a, int b) : m_a(a), m_b(b) {}
5575 virtual int test() { return 5; }
5580 class B5106 : public A5106
5583 B5106(int c, int a, int b) : A5106(a, b), m_c(c) {}
5584 virtual int test() { return 4; BREAK_HERE; }
5596 } // namespace bug5106
5601 // https://bugreports.qt-project.org/browse/QTCREATORBUG-5184
5603 // Note: The report there shows type field "QUrl &" instead of QUrl.
5604 // It's unclear how this can happen. It should never have been like
5605 // that with a stock 7.2 and any version of Creator.
5607 void helper(const QUrl &url)
5609 QNetworkRequest request(url);
5610 QList<QByteArray> raw = request.rawHeaderList();
5612 // Check raw <0 items> QList<QByteArray>.
5613 // CheckType request QNetworkRequest.
5614 // Check url "http://127.0.0.1/" QUrl.
5616 dummyStatement(&request, &raw);
5621 QUrl url(QString("http://127.0.0.1/"));
5625 } // namespace bug5184
5630 // http://www.qtcentre.org/threads/42170-How-to-watch-data-of-actual-type-in-debugger
5634 Object(int id_) : id(id_) {}
5635 virtual ~Object() {}
5639 struct Point : Object
5641 Point(double x_, double y_) : Object(1), x(x_), y(y_) {}
5645 struct Circle : Point
5647 Circle(double x_, double y_, double r_) : Point(x_, y_), r(r_) { id = 2; }
5651 void helper(Object *obj)
5654 // CheckType obj qc42170::Circle.
5657 // Check that obj is shown as a 'Circle' object.
5658 dummyStatement(obj);
5663 Circle *circle = new Circle(1.5, -2.5, 3.0);
5664 Object *obj = circle;
5669 } // namespace qc42170
5674 // https://bugreports.qt-project.org/browse/QTCREATORBUG-5799
5676 typedef struct { int m1; int m2; } S1;
5680 typedef struct S3 { int m1; int m2; } S3;
5691 typedef S1 Array[10];
5694 // Expand s2 s2.@1 s4 s4.@1
5695 // CheckType a1 bug5799::S1 [10].
5696 // CheckType a2 bug5799::Array.
5697 // CheckType s2 bug5799::S2.
5698 // CheckType s2.@1 bug5799::S1.
5699 // Check s2.@1.m1 5 int.
5700 // CheckType s2.@1.m2 int.
5701 // CheckType s4 bug5799::S4.
5702 // CheckType s4.@1 bug5799::S3.
5703 // Check s4.@1.m1 5 int.
5704 // CheckType s4.@1.m2 int.
5706 dummyStatement(&s2, &s4, &a1, &a2);
5709 } // namespace bug5799
5714 // https://bugreports.qt-project.org/browse/QTCREATORBUG-6813
5719 //std::cout << "&foo: " << &foo << "; bar: " << bar << "; &bar: " << &bar;
5720 dummyStatement(&foo, &bar);
5723 } // namespace bug6813
5728 // http://www.qtcentre.org/threads/41700-How-to-watch-STL-containers-iterators-during-debugging
5732 using namespace std;
5733 typedef map<string, list<string> > map_t;
5735 m["one"].push_back("a");
5736 m["one"].push_back("b");
5737 m["one"].push_back("c");
5738 m["two"].push_back("1");
5739 m["two"].push_back("2");
5740 m["two"].push_back("3");
5741 map_t::const_iterator it = m.begin();
5743 // Expand m m.0 m.0.second m.1 m.1.second.
5744 // Check m <2 items> qc41700::map_t.
5745 // Check m.0 std::pair<std::string const, std::list<std::string>>.
5746 // Check m.0.first "one" std::string.
5747 // Check m.0.second <3 items> std::list<std::string>.
5748 // Check m.0.second.0 "a" std::string.
5749 // Check m.0.second.1 "b" std::string.
5750 // Check m.0.second.2 "c" std::string.
5751 // Check m.1 std::pair<std::string const, std::list<std::string>>.
5752 // Check m.1.first "two" std::string.
5753 // Check m.1.second <3 items> std::list<std::string>.
5754 // Check m.1.second.0 "1" std::string.
5755 // Check m.1.second.1 "2" std::string.
5756 // Check m.1.second.2 "3" std::string.
5758 dummyStatement(&it);
5761 } // namespace qc41700
5766 // http://codepaster.europe.nokia.com/?id=42895
5768 void g(int c, int d)
5775 // Check there are frames for g and f in the stack view.
5776 dummyStatement(&c, &d);
5779 void f(int a, int b)
5794 // https://bugreports.qt-project.org/browse/QTCREATORBUG-6465
5798 typedef char Foo[20];
5800 char bar[20] = "baz";
5802 dummyStatement(&foo, &bar);
5805 } // namespace bug6465
5810 class MyFile : public QFile
5813 MyFile(const QString &fileName)
5814 : QFile(fileName) {}
5819 MyFile file("/tmp/tt");
5820 file.setObjectName("A file");
5823 // Check file "A file" bug6857::MyFile.
5824 // Check file.@1 "/tmp/tt" QFile.
5826 dummyStatement(&file);
5833 class MyFile : public QFile
5836 MyFile(const QString &fileName)
5837 : QFile(fileName) {}
5842 MyFile file("/tmp/tt");
5843 file.setObjectName("Another file");
5844 QFile *pfile = &file;
5846 // Check pfile "Another file" bug6858::MyFile.
5847 // Check pfile.@1 "/tmp/tt" QFile.
5849 dummyStatement(&file, pfile);
5856 class MyObject : public QObject
5863 void setProp(QObject *obj)
5865 obj->setProperty("foo", "bar");
5868 // Check obj.[QObject].properties <2 items>.
5870 dummyStatement(&obj);
5875 QFile file("/tmp/tt");
5894 class Derived : public Base
5897 Derived() : b(42) {}
5906 // Expand b b.bug6933::Base
5907 // Check b.[bug6933::Base].[vptr]
5908 // Check b.b 42 int.
5910 dummyStatement(&d, b);
5916 void test(const char *format, ...)
5919 va_start(arg, format);
5920 int i = va_arg(arg, int);
5921 double f = va_arg(arg, double);
5923 dummyStatement(&i, &f);
5928 test("abc", 1, 2.0);
5931 } // namespace varargs
5934 namespace gdb13393 {
5938 virtual ~Base() {} // Enforce type to have RTTI
5943 struct Derived : public Base {
5951 const Base *ptrConst;
5953 const Base &refConst;
5956 : ptr(&d), ptrConst(&d), ref(d), refConst(d)
5965 const Base *ptrConst = &d;
5967 const Base &refConst = d;
5968 Base **ptrToPtr = &ptr;
5970 boost::shared_ptr<Base> sharedPtr(new Derived());
5975 // Expand d ptr ptr.@1 ptrConst ptrToPtr ref refConst s.
5976 // CheckType d gdb13393::Derived.
5977 // CheckType d.@1 gdb13393::Base.
5979 // CheckType ptr gdb13393::Derived.
5980 // CheckType ptr.@1 gdb13393::Base.
5981 // Check ptr.@1.a 1 int.
5982 // CheckType ptrConst gdb13393::Derived.
5983 // CheckType ptrConst.@1 gdb13393::Base.
5984 // Check ptrConst.b 2 int.
5985 // CheckType ptrToPtr gdb13393::Derived.
5986 // CheckType ptrToPtr.[vptr] .
5987 // Check ptrToPtr.@1.a 1 int.
5988 // CheckType ref gdb13393::Derived.
5989 // CheckType ref.[vptr] .
5990 // Check ref.@1.a 1 int.
5991 // CheckType refConst gdb13393::Derived.
5992 // CheckType refConst.[vptr] .
5993 // Check refConst.@1.a 1 int.
5994 // CheckType s gdb13393::S.
5995 // CheckType s.ptr gdb13393::Derived.
5996 // CheckType s.ptrConst gdb13393::Derived.
5997 // CheckType s.ref gdb13393::Derived.
5998 // CheckType s.refConst gdb13393::Derived.
5999 // Check sharedPtr 1 int.
6001 dummyStatement(&d, &s, &ptrToPtr, &sharedPtr, &ptrConst, &refConst, &ref);
6004 } // namespace gdb13393
6007 namespace gdb10586 {
6009 // http://sourceware.org/bugzilla/show_bug.cgi?id=10586. fsf/MI errors out
6010 // on -var-list-children on an anonymous union. mac/MI was fixed in 2006.
6011 // The proposed fix has been reported to crash gdb steered from eclipse.
6012 // http://sourceware.org/ml/gdb-patches/2011-12/msg00420.html
6013 // Check we are not harmed by either version.
6017 struct { int a; float b; };
6018 struct { int c; float d; };
6019 } v = {{1, 2}, {3, 4}};
6022 // Check v gdb10586::test.
6030 struct { int x; struct { int a; }; struct { int b; }; } v = {1, {2}, {3}};
6031 struct s { int x, y; } n = {10, 20};
6035 // CheckType v {...}.
6036 // CheckType n gdb10586::s.
6040 // Check n.x 10 int.
6041 // Check n.y 20 int.
6043 dummyStatement(&v, &n);
6052 } // namespace gdb10586
6055 namespace valgrind {
6059 new int[100]; // Leaks intentionally.
6067 } // namespace valgrind
6072 // A very quick check.
6086 list << "aaa" << "bbb" << "cc";
6088 QList<const char *> list2;
6096 obj.setObjectName("An Object");
6099 // Check list <3 items> QStringList
6100 // Check list2 <5 items> QList<char const*>
6101 // Check obj "An Object" QObject
6102 // Check qv <1 items> QVector<int>
6103 // Check s "hallohallo" std::string
6104 // Check v <1 items> std::vector<int>
6107 dummyStatement(&s, &qv, &v, &list, &list2, &obj);
6110 } // namespace sanity
6113 int main(int argc, char *argv[])
6115 QApplication app(argc, argv);
6117 // Notify Creator about auto run intention.
6119 qWarning("Creator: Switch on magic autorun.");
6121 qWarning("Creator: Switch off magic autorun.");
6123 // For a very quick check, step into this one.
6124 sanity::testSanity();
6126 // Check for normal dumpers.
6128 qhostaddress::testQHostAddress();
6129 varargs::testVaList();
6131 formats::testFormats();
6132 breakpoints::testBreakpoints();
6133 peekandpoke::testPeekAndPoke3();
6134 anon::testAnonymous();
6136 itemmodel::testItemModel();
6137 noargs::testNoArgumentName(1, 2, 3);
6140 catchthrow::testCatchThrow();
6141 plugin::testPlugin();
6142 valgrind::testValgrind();
6143 namespc::testNamespace();
6144 painting::testPainting();
6146 stdarray::testStdArray();
6147 stdcomplex::testStdComplex();
6148 stddeque::testStdDeque();
6149 stdlist::testStdList();
6150 stdhashset::testStdHashSet();
6151 stdmap::testStdMap();
6152 stdset::testStdSet();
6153 stdstack::testStdStack();
6154 stdstream::testStdStream();
6155 stdstring::testStdString();
6156 stdvector::testStdVector();
6157 stdptr::testStdPtr();
6159 qbytearray::testQByteArray();
6160 qdatetime::testDateTime();
6162 qfileinfo::testQFileInfo();
6164 qlinkedlist::testQLinkedList();
6166 qlocale::testQLocale();
6168 qobject::testQObject();
6169 qrect::testGeometry();
6170 qregexp::testQRegExp();
6171 qregion::testQRegion();
6172 qscript::testQScript();
6174 qsharedpointer::testQSharedPointer();
6175 qstack::testQStack();
6176 qstringlist::testQStringList();
6177 qstring::testQString();
6178 qthread::testQThread();
6180 qvariant::testQVariant();
6181 qvector::testQVector();
6182 qxml::testQXmlAttributes();
6184 // Third party data types.
6191 // The following tests are specific to certain bugs.
6192 // They need not to be checked during a normal release check.
6193 cp42895::test42895();
6194 bug5046::test5046();
6195 bug4904::test4904();
6196 qc41700::test41700();
6197 qc42170::test42170();
6198 multibp::testMultiBp();
6200 bug3611::test3611();
6201 bug4019::test4019();
6202 bug4997::test4997();
6203 bug5106::test5106();
6204 bug5184::test5184();
6205 bug5799::test5799();
6206 bug6813::test6813();
6207 bug6465::test6465();
6208 bug6857::test6857();
6209 bug6858::test6858();
6210 bug6863::test6863();
6211 bug6933::test6933();
6212 gdb13393::test13393();
6213 gdb10586::test10586();
6215 final::testFinal(&app);
6220 #include "simple_test_app.moc"