simple_gdbtest_app.cpp 52.8 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
29
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
con's avatar
con committed
32

33
34
35
36
//#include <complex>

//template <typename T> class B;  B foo() {}

37
#include "../simple/deep/deep/simple_gdbtest_app.h"
38

con's avatar
con committed
39
#include <QtCore/QDebug>
40
#include <QtCore/QDateTime>
con's avatar
con committed
41
42
43
#include <QtCore/QDir>
#include <QtCore/QHash>
#include <QtCore/QLibrary>
44
45
#include <QtCore/QLinkedList>
#include <QtCore/QList>
con's avatar
con committed
46
47
#include <QtCore/QMap>
#include <QtCore/QPointer>
48
#include <QtCore/QProcess>
hjk's avatar
hjk committed
49
#include <QtCore/QRegExp>
con's avatar
con committed
50
#include <QtCore/QString>
51
#include <QtCore/QStringList>
hjk's avatar
hjk committed
52
#include <QtCore/QSettings>
hjk's avatar
hjk committed
53
#include <QtCore/QStack>
con's avatar
con committed
54
55
56
#include <QtCore/QThread>
#include <QtCore/QVariant>
#include <QtCore/QVector>
hjk's avatar
hjk committed
57
#include <QtCore/QUrl>
58
#if QT_VERSION >= 0x040500
59
#include <QtCore/QSharedPointer>
60
#endif
con's avatar
con committed
61
62
63
64
65
66

#include <QtGui/QApplication>
#include <QtGui/QAction>
#include <QtGui/QColor>
#include <QtGui/QFont>
#include <QtGui/QLabel>
hjk's avatar
hjk committed
67
//#include <QtGui/private/qfixed_p.h>
con's avatar
con committed
68
69
#include <QtGui/QPainter>
#include <QtGui/QPainterPath>
70
#include <QtGui/QRegion>
71
#include <QtGui/QStandardItemModel>
72
73
#include <QtGui/QTextCursor>
#include <QtGui/QTextDocument>
con's avatar
con committed
74

75
76
77
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptValue>

hjk's avatar
hjk committed
78
79
#include <QtXml/QXmlAttributes>

con's avatar
con committed
80
81
#include <QtNetwork/QHostAddress>

hjk's avatar
hjk committed
82
#include <deque>
con's avatar
con committed
83
#include <iostream>
84
#include <map>
hjk's avatar
hjk committed
85
#include <list>
86
#include <set>
hjk's avatar
hjk committed
87
#include <stack>
con's avatar
con committed
88
89
90
#include <string>
#include <vector>

91
#define USE_PRIVATE 1
92
//#define USE_BOOST 1
hjk's avatar
hjk committed
93
//#define USE_EIGEN 1
94
95

#if USE_BOOST
96
#include <boost/optional.hpp>
97
98
#include <boost/shared_ptr.hpp>
#endif
99

hjk's avatar
hjk committed
100
101
102
103
#if USE_EIGEN
#include <eigen2/Eigen/Core>
#endif

104
105
106
107
#if USE_PRIVATE
#include <QtCore/private/qobject_p.h>
#endif

108
#if defined(__GNUC__) && !defined(__llvm__) && !defined(Q_OS_MAC)
109
#    define USE_GCC_EXT 1
110
#    undef __DEPRECATED
111
#    include <ext/hash_set>
112
113
#endif

con's avatar
con committed
114
115
#ifdef Q_OS_WIN
#include <windows.h>
116
117
#undef min
#undef max
con's avatar
con committed
118
119
#endif

120
#ifdef __SSE__
hjk's avatar
hjk committed
121
122
123
#include <xmmintrin.h>
#include <stddef.h>
#endif
124
125
126
127
128
129
130
131
Q_DECLARE_METATYPE(QHostAddress)
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QStringList)

typedef QMap<uint, QStringList> MyType;
#define COMMA ,
Q_DECLARE_METATYPE(QMap<uint COMMA QStringList>)

132
133
134
135
136
137
138
139
140
141
142
143
template <typename T> class Vector
{
public:
    explicit Vector(int size) : m_size(size), m_data(new T[size]) {}
    ~Vector() { delete [] m_data; }
    //...
private:
    int m_size;
    T *m_data;
};


144
145
146
147
148
149
namespace nsX {
namespace nsY {
int z;
}
}

hjk's avatar
hjk committed
150

151
152
153
154
155
#if USE_PRIVATE

class DerivedObjectPrivate : public QObjectPrivate
{
public:
156
157
158
159
    DerivedObjectPrivate()
    {
        m_extraX = 43;
        m_extraY.append("xxx");
160
        m_extraZ = 1;
161
    }
162
163

    int m_extraX;
164
    QStringList m_extraY;
165
    uint m_extraZ : 1;
166
    bool m_extraA : 1;
167
    bool m_extraB;
168
169
170
171
172
173
174
};

class DerivedObject : public QObject
{
    Q_OBJECT

public:
hjk's avatar
hjk committed
175
176
177
    DerivedObject()
       : QObject(*new DerivedObjectPrivate, 0)
    {}
178
179

    Q_PROPERTY(int x READ x WRITE setX)
180
    Q_PROPERTY(QStringList y READ y WRITE setY)
181
    Q_PROPERTY(uint z READ z WRITE setZ)
182
183
184

    int x() const;
    void setX(int x);
185
186
    QStringList y() const;
    void setY(QStringList y);
187
188
    uint z() const;
    void setZ(uint z);
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

private:
    Q_DECLARE_PRIVATE(DerivedObject)
};

int DerivedObject::x() const
{
    Q_D(const DerivedObject);
    return d->m_extraX;
}

void DerivedObject::setX(int x)
{
    Q_D(DerivedObject);
    d->m_extraX = x;
204
205
    d->m_extraA = !d->m_extraA;
    d->m_extraB = !d->m_extraB;
206
207
}

208
QStringList DerivedObject::y() const
209
210
211
212
213
{
    Q_D(const DerivedObject);
    return d->m_extraY;
}

214
void DerivedObject::setY(QStringList y)
215
216
217
218
219
{
    Q_D(DerivedObject);
    d->m_extraY = y;
}

220
221
222
223
224
225
226
227
228
229
230
231
uint DerivedObject::z() const
{
    Q_D(const DerivedObject);
    return d->m_extraZ;
}

void DerivedObject::setZ(uint z)
{
    Q_D(DerivedObject);
    d->m_extraZ = z;
}

232
233
#endif

234
235
236
237
struct S
{
    uint x : 1;
    uint y : 1;
238
    bool c : 1;
239
240
241
    bool b;
    float f;
    double d;
242
    qreal q;
243
    int i;
244
};
245
246
247

void testPrivate()
{
248
249
    S s;
    s.x = 1;
250
251
252
253
254
255
256
257
258
259
#if USE_PRIVATE
    DerivedObject ob;
    ob.setX(23);
    ob.setX(25);
    ob.setX(26);
    ob.setX(63);
    ob.setX(32);
#endif
}

260
261
262
263
264
265
namespace nsXY = nsX::nsY;

int qwert()
{
    return nsXY::z;
}
con's avatar
con committed
266
267
268
269
270
271
272
273
274
275
276

uint qHash(const QMap<int, int> &)
{
    return 0;
}

uint qHash(const double & f)
{
    return int(f);
}

hjk's avatar
hjk committed
277

hjk's avatar
hjk committed
278
class Foo
con's avatar
con committed
279
280
{
public:
hjk's avatar
hjk committed
281
    Foo(int i = 0)
con's avatar
con committed
282
283
284
285
286
287
        : a(i), b(2)
    {
        int s = 1;
        int t = 2;
        b = 2 + s + t;
        a += 1;
288
289
290
291
292
293
294
295
296
297
298
299
300
301
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
        a += 1;
con's avatar
con committed
302
    }
303

304
    virtual ~Foo()
305
306
307
308
    {
        a = 5;
    }

con's avatar
con committed
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
    void doit()
    {
        static QObject ob;
        m["1"] = "2";
        h[&ob] = m.begin();

        a += 1;
        --b;
        //s += 'x';
    }


    struct Bar {
        Bar() : ob(0) {}
        QObject *ob;
    };

public:
    int a, b;
    char x[6];

private:
    //QString s;
    typedef QMap<QString, QString> Map;
    Map m;
    QHash<QObject *, Map::iterator> h;
};

337
class X : public Foo
hjk's avatar
hjk committed
338
339
340
341
342
343
{
public:
    X() {
    }
};

344
345
346
347
348
349
350
class XX : virtual public Foo
{
public:
    XX() {
    }
};

hjk's avatar
hjk committed
351
352
353
354
355
356
357
class Y : virtual public Foo
{
public:
    Y() {
    }
};

358
359
360
361
362
class D : public X, public Y
{
    int diamond;
};

con's avatar
con committed
363
364
void testArray()
{
365
366
367
368
#if 1
    X x;
    XX xx;
    D diamond;
369
    Q_UNUSED(diamond);
370
    Foo *f = &xx;
371
    Q_UNUSED(f);
372
    Foo ff;
373
    Q_UNUSED(ff);
374
375
376
377
    double d[3][3];
    for (int i = 0; i != 3; ++i)
        for (int j = 0; j != 3; ++j)
            d[i][j] = i + j;
378
    Q_UNUSED(d);
379
#endif
380

381
#if 1
hjk's avatar
hjk committed
382
383
384
385
386
    char c[20];
    c[0] = 'a';
    c[1] = 'b';
    c[2] = 'c';
    c[3] = 'd';
387
    Q_UNUSED(c);
388
#endif
hjk's avatar
hjk committed
389

390
391
392
393
394
395
#if 1
    QString s[20];
    s[0] = "a";
    s[1] = "b";
    s[2] = "c";
    s[3] = "d";
396
    Q_UNUSED(s);
397
#endif
con's avatar
con committed
398

399
400
401
402
403
404
#if 1
    QByteArray b[20];
    b[0] = "a";
    b[1] = "b";
    b[2] = "c";
    b[3] = "d";
405
    Q_UNUSED(b);
406
407
408
#endif

#if 1
con's avatar
con committed
409
410
411
412
413
414
    Foo foo[10];
    //for (int i = 0; i != sizeof(foo)/sizeof(foo[0]); ++i) {
    for (int i = 0; i < 5; ++i) {
        foo[i].a = i;
        foo[i].doit();
    }
415
#endif
con's avatar
con committed
416
417
}

418
#ifndef Q_CC_RVCT
419
420
421
422
423
424
425
426
struct TestAnonymous
{
    union {
        struct { int i; int b; };
        struct { float f; };
        double d;
    };
};
427
#endif
hjk's avatar
hjk committed
428
429
430
431
432

void testPeekAndPoke3()
{
    // Anonymous structs
    {
433
#ifndef Q_CC_RVCT
hjk's avatar
hjk committed
434
435
436
437
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
438
        } a = { { 42, 43 } };
hjk's avatar
hjk committed
439
440
441
        a.i = 1; // Break here. Expand a. Step.
        a.i = 2; // Change a.i in Locals view to 0. This changes f, d but expectedly not b. Step.
        a.i = 3; // Continue.
442
        Q_UNUSED(a);
443
#endif
hjk's avatar
hjk committed
444
445
446
447
448
449
450
451
452
    }

    // Complex watchers
    {
        struct S { int a; double b; } s[10];
        for (int i = 0; i != 10; ++i) {
            s[i].a = i;  // Break here. Expand s and s[0]. Step.
            // Watcher Context: "Add New Watcher".
            // Type    ['s[%d].a' % i for i in range(5)]
453
454
            // Expand it, continue stepping. This should result in a list
            // of five items containing the .a fields of s[0]..s[4].
hjk's avatar
hjk committed
455
        }
456
        Q_UNUSED(s);
hjk's avatar
hjk committed
457
    }
hjk's avatar
hjk committed
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474

    // QImage display
    {
        QImage im(QSize(200, 200), QImage::Format_RGB32);
        im.fill(QColor(200, 10, 30).rgba());
        QPainter pain;
        pain.begin(&im);
        pain.setPen(QPen(Qt::black, 5.0, Qt::SolidLine, Qt::RoundCap));
        pain.drawEllipse(20, 20, 160, 160); // Break here. Step.
        // Toggle between "Normal" and "Displayed" in L&W Context Menu, entry "Display of Type QImage". Step.
        pain.drawArc(70, 115, 60, 30, 200 * 16, 140 * 16);
        pain.setBrush(Qt::black);
        pain.drawEllipse(65, 70, 15, 15); // Step.
        pain.drawEllipse(120, 70, 15, 15); // Step.
        pain.end();
    }

hjk's avatar
hjk committed
475
}
476

477
478

#ifndef Q_CC_RVCT
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
namespace { // anon

struct Something
{
    Something() { a = b = 1; }

    void foo()
    {
        a = 42;
        b = 43;
    }

    int a, b;
};

} // anon
495
496
#endif

497

498
499
void testAnonymous()
{
500
#ifndef Q_CC_RVCT
501
502
503
504
    TestAnonymous a;
    a.i = 1;
    a.i = 2;
    a.i = 3;
505
    Q_UNUSED(a);
506
507
508

    Something s;
    s.foo();
509
    Q_UNUSED(s);
510
#endif
511
512
}

513
514
typedef void (*func_t)();
func_t testFunctionPointer()
515
516
{
    func_t f1 = testAnonymous;
517
518
    func_t f2 = testPeekAndPoke3;
    func_t f3 = testPeekAndPoke3;
519
520
521
    Q_UNUSED(f1);
    Q_UNUSED(f2);
    Q_UNUSED(f3);
522
    return f1;
523
524
}

525
void testQByteArray()
con's avatar
con committed
526
527
528
529
{
    QByteArray ba = "Hello";
    ba += '"';
    ba += "World";
hjk's avatar
hjk committed
530
531
532
533
534
535
536
537

    const char *str1 = "\356";
    const char *str2 = "\xee";
    const char *str3 = "\\ee";
    QByteArray buf1( str1 );
    QByteArray buf2( str2 );
    QByteArray buf3( str3 );

con's avatar
con committed
538
539
540
541
542
    ba += char(0);
    ba += 1;
    ba += 2;
}

543
544
545
546
547
int testQByteArray2()
{
    QByteArray ba;
    for (int i = 256; --i >= 0; )
        ba.append(char(i));
548
549
    QString s(10000, 'x');
    std::string ss(10000, 'c');
550
551
552
    return ba.size();
}

553
554
555
556
557
558
559
560
561
562
563
564
static void throwit1()
{
    throw 14;
}

static void throwit()
{
    throwit1();
}

int testCatchThrow()
{
565
566
    // Set a breakpoint on "throw" in the BreakWindow context menu
    // before stepping further.
567
568
569
570
571
572
573
574
575
    int gotit = 0;
    try {
        throwit();
    } catch (int what) {
        gotit = what;
    }
    return gotit;
}

576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
void testQDate()
{
    QDate date;
    date = QDate::currentDate();
    date = date.addDays(5);
    date = date.addDays(5);
    date = date.addDays(5);
    date = date.addDays(5);
}

void testQTime()
{
    QTime time;
    time = QTime::currentTime();
    time = time.addSecs(5);
    time = time.addSecs(5);
    time = time.addSecs(5);
    time = time.addSecs(5);
}

void testQDateTime()
597
598
599
600
601
602
603
604
605
{
    QDateTime date;
    date = QDateTime::currentDateTime();
    date = date.addSecs(5);
    date = date.addSecs(5);
    date = date.addSecs(5);
    date = date.addSecs(5);
}

606
QFileInfo testQFileInfo()
607
{
608
    QFile file("/tmp/t");
609
610
    QFileInfo fi("/tmp/t");
    QString s = fi.absoluteFilePath();
611
612
613
    s = fi.bundleName();
    s = fi.bundleName();
    s = fi.bundleName();
614
615
616

    QFileInfo result("/tmp/t");
    return result;
617
618
}

hjk's avatar
hjk committed
619
620
void testQFixed()
{
hjk's avatar
hjk committed
621
/*
hjk's avatar
hjk committed
622
623
624
625
626
627
628
    QFixed f = QFixed::fromReal(4.2);
    f += 1;
    f += 1;
    f *= -1;
    f += 1;
    f += 1;
*/
629
630
}

631
QHash<int, float> testQHash()
con's avatar
con committed
632
{
hjk's avatar
hjk committed
633
#if 1
con's avatar
con committed
634
635
636
    QHash<int, float> hgg0;
    hgg0[11] = 11.0;
    hgg0[22] = 22.0;
637
638
639
640
641
    hgg0[22] = 22.0;
    hgg0[22] = 22.0;
    hgg0[22] = 22.0;
    hgg0[22] = 22.0;
    hgg0[22] = 22.0;
con's avatar
con committed
642

643
644
645
#endif

#if 1
con's avatar
con committed
646

647
    QHash<QString, int> hgg1;
con's avatar
con committed
648
    hgg1["22.0"] = 22.0;
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
    hgg1["123.0"] = 22.0;
    hgg1["111111ss111128.0"] = 28.0;
    hgg1["11124.0"] = 22.0;
    hgg1["1111125.0"] = 22.0;
    hgg1["11111126.0"] = 22.0;
    hgg1["111111127.0"] = 27.0;
    hgg1["111111111128.0"] = 28.0;
    hgg1["111111111111111111129.0"] = 29.0;

    QHash<QByteArray, float> hgx1;
    hgx1["22.0"] = 22.0;
    hgx1["123.0"] = 22.0;
    hgx1["111111ss111128.0"] = 28.0;
    hgx1["11124.0"] = 22.0;
    hgx1["1111125.0"] = 22.0;
    hgx1["11111126.0"] = 22.0;
    hgx1["111111127.0"] = 27.0;
    hgx1["111111111128.0"] = 28.0;
    hgx1["111111111111111111129.0"] = 29.0;
668
#endif
669
#if 1
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
670
671
    QHash<int, QString> hgg2;
    hgg2[22] = "22.0";
con's avatar
con committed
672
673
674
675
676
677
678
679
680
681

    QHash<QString, Foo> hgg3;
    hgg3["22.0"] = Foo(22);
    hgg3["33.0"] = Foo(33);

    QObject ob;
    QHash<QString, QPointer<QObject> > hash;
    hash.insert("Hallo", QPointer<QObject>(&ob));
    hash.insert("Welt", QPointer<QObject>(&ob));
    hash.insert(".", QPointer<QObject>(&ob));
682
#endif
683
684
    QHash<int, float> result;
    return result;
con's avatar
con committed
685
686
}

687
void testQImage()
con's avatar
con committed
688
{
689
    // only works with Python dumper
con's avatar
con committed
690
691
692
693
694
695
696
697
698
699
    QImage im(QSize(200, 200), QImage::Format_RGB32);
    im.fill(QColor(200, 100, 130).rgba());
    QPainter pain;
    pain.begin(&im);
    pain.drawLine(2, 2, 130, 130);
    pain.drawLine(4, 2, 130, 140);
    pain.drawRect(30, 30, 80, 80);
    pain.end();
}

700
701
702
703
704
705
706
707
708
709
710
711
struct Function
{
    Function(QByteArray var, QByteArray f, double min, double max)
      : var(var), f(f), min(min), max(max) {}
    QByteArray var;
    QByteArray f;
    double min;
    double max;
};

void testFunction()
{
hjk's avatar
hjk committed
712
    // In order to use this, switch on the 'qDump__Function' in gdbmacros.py
713
714
715
716
717
718
719
720
721
722
    Function func("x", "sin(x)", 0, 1);
    func.max = 10;
    func.f = "cos(x)";
    func.max = 4;
    func.max = 5;
    func.max = 6;
    func.max = 7;
    func.max = 8;
}

723
void testOutput()
con's avatar
con committed
724
725
726
727
{
    qDebug() << "qDebug() 1";
    qDebug() << "qDebug() 2";
    qDebug() << "qDebug() 3";
728
    qDebug() << "qDebug <foo & bar>";
con's avatar
con committed
729
730
731
732

    std::cout << "std::cout @@ 1" << std::endl;
    std::cout << "std::cout @@ 2\n";
    std::cout << "std::cout @@ 3" << std::endl;
733
    std::cout << "std::cout <foo & bar>\n";
con's avatar
con committed
734
735
736
737

    std::cerr << "std::cerr 1\n";
    std::cerr << "std::cerr 2\n";
    std::cerr << "std::cerr 3\n";
738
    std::cerr << "std::cerr <foo & bar>\n";
con's avatar
con committed
739
740
}

741
742
743
744
745
746
747
748
749
750
751
752
void testInput()
{
#if 0
    // This works only when "Run in terminal" is selected
    // in the Run Configuration.
    int i;
    std::cin >> i;
    int j;
    std::cin >> j;
#endif
}

753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
void testQLinkedList()
{
#if 1
    QLinkedList<int> li;
    QLinkedList<uint> lu;

    for (int i = 0; i != 3; ++i)
        li.append(i);
    li.append(102);


    lu.append(102);
    lu.append(102);
    lu.append(102);

hjk's avatar
hjk committed
768
769
770
771
772
    QLinkedList<Foo *> lpi;
    lpi.append(new Foo(1));
    lpi.append(0);
    lpi.append(new Foo(3));

773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
    QLinkedList<qulonglong> l;
    l.append(42);
    l.append(43);
    l.append(44);
    l.append(45);

    QLinkedList<Foo> f;
    f.append(Foo(1));
    f.append(Foo(2));
#endif
    QLinkedList<std::string> v;
    v.push_back("aa");
    v.push_back("bb");
    v.push_back("cc");
    v.push_back("dd");
 }
con's avatar
con committed
789

790
791
792
void testQLocale()
{
    QLocale loc = QLocale::system();
793
    //QString s = loc.name();
794
    //QVariant v = loc;
795
    QLocale::MeasurementSystem m = loc.measurementSystem();
796
    Q_UNUSED(m);
797
798
}

799
void testQList()
con's avatar
con committed
800
{
801
802
803
804
805
806
807
808
809
810
    QList<int> big;
    for (int i = 0; i < 10000; ++i)
        big.push_back(i);

    QList<Foo> flist;
    for (int i = 0; i < 100; ++i)
        flist.push_back(i + 15);
    flist.push_back(1000);
    flist.push_back(1001);
    flist.push_back(1002);
811
#if 1
con's avatar
con committed
812
813
814
    QList<int> li;
    QList<uint> lu;

815
    for (int i = 0; i != 30; ++i) {
con's avatar
con committed
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
        li.append(i);
    }
    li.append(101);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);
    li.append(102);

833
834
835
836
837
    QList<int *> lpi;
    lpi.append(new int(1));
    lpi.append(new int(2));
    lpi.append(new int(3));

con's avatar
con committed
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852

    for (int i = 0; i != 3; ++i) {
        lu.append(i);
    }
    lu.append(101);
    lu.append(102);
    lu.append(102);
    lu.append(102);

    QList<uint> i;
    i.append(42);
    i.append(43);
    i.append(44);
    i.append(45);

853
854
855
856
857
858
859
860
861
862
863
864
    QList<ushort> ls;
    ls.append(42);
    ls.append(43);
    ls.append(44);
    ls.append(45);

    QList<QChar> lc;
    lc.append(QChar('a'));
    lc.append(QChar('b'));
    lc.append(QChar('c'));
    lc.append(QChar('d'));

con's avatar
con committed
865
866
867
868
869
870
871
872
873
874
    QList<qulonglong> l;
    l.append(42);
    l.append(43);
    l.append(44);
    l.append(45);

    QList<Foo> f;
    f.append(Foo(1));
    f.append(Foo(2));

875
    QList<std::string> v;
con's avatar
con committed
876
877
878
879
    v.push_back("aa");
    v.push_back("bb");
    v.push_back("cc");
    v.push_back("dd");
880
#endif
con's avatar
con committed
881
882
 }

883
884
namespace nsA {
namespace nsB {
885
886
887
888
889
890
891

struct SomeType
{
    SomeType(int a) : a(a) {}
    int a;
};

892
893
} // namespace nsB
} // namespace nsA
894

895
void testQMap()
con's avatar
con committed
896
{
897
#if 0
con's avatar
con committed
898
899
900
901
902
903
904
905
    QMap<uint, QStringList> ggl;
    ggl[11] = QStringList() << "11";
    ggl[22] = QStringList() << "22";

    typedef QMap<uint, QStringList> T;
    T ggt;
    ggt[11] = QStringList() << "11";
    ggt[22] = QStringList() << "22";
906
#endif
con's avatar
con committed
907

908
#if 0
con's avatar
con committed
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
    QMap<uint, float> gg0;
    gg0[11] = 11.0;
    gg0[22] = 22.0;


    QMap<QString, float> gg1;
    gg1["22.0"] = 22.0;

    QMap<int, QString> gg2;
    gg2[22] = "22.0";

    QMap<QString, Foo> gg3;
    gg3["22.0"] = Foo(22);
    gg3["33.0"] = Foo(33);

    QObject ob;
    QMap<QString, QPointer<QObject> > map;
    map.insert("Hallo", QPointer<QObject>(&ob));
    map.insert("Welt", QPointer<QObject>(&ob));
    map.insert(".", QPointer<QObject>(&ob));
#endif
930
931

#if 1
932
933
934
935
936
    QList<nsA::nsB::SomeType *> x;
    x.append(new nsA::nsB::SomeType(1));
    x.append(new nsA::nsB::SomeType(2));
    x.append(new nsA::nsB::SomeType(3));
    QMap<QString, QList<nsA::nsB::SomeType *> > mlt;
937
938
939
940
941
    mlt["foo"] = x;
    mlt["bar"] = x;
    mlt["1"] = x;
    mlt["2"] = x;
#endif
con's avatar
con committed
942
943
}

hjk's avatar
hjk committed
944
945
946
947
948
949
void testQMultiMap()
{
    QMultiMap<uint, float> gg0;
    gg0.insert(11, 11.0);
    gg0.insert(22, 22.0);
    gg0.insert(22, 33.0);
hjk's avatar
hjk committed
950
951
952
953
    gg0.insert(22, 34.0);
    gg0.insert(22, 35.0);
    gg0.insert(22, 36.0);
#if 1
hjk's avatar
hjk committed
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
    QMultiMap<QString, float> gg1;
    gg1.insert("22.0", 22.0);

    QMultiMap<int, QString> gg2;
    gg2.insert(22, "22.0");

    QMultiMap<QString, Foo> gg3;
    gg3.insert("22.0", Foo(22));
    gg3.insert("33.0", Foo(33));
    gg3.insert("22.0", Foo(22));

    QObject ob;
    QMultiMap<QString, QPointer<QObject> > map;
    map.insert("Hallo", QPointer<QObject>(&ob));
    map.insert("Welt", QPointer<QObject>(&ob));
    map.insert(".", QPointer<QObject>(&ob));
    map.insert(".", QPointer<QObject>(&ob));
hjk's avatar
hjk committed
971
#endif
hjk's avatar
hjk committed
972
973
}

974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
namespace Names {
namespace Bar {

struct Ui {
    Ui() { w = 0; }
    QWidget *w;
};

class TestObject : public QObject
{
    Q_OBJECT

public:
    TestObject(QObject *parent = 0)
      : QObject(parent)
    {
        m_ui = new Ui;
991
        m_ui->w = new QWidget;
992
        Q_UNUSED(parent);
993
994
    }

995
996
997
998
999
1000
    Q_PROPERTY(QString myProp1 READ myProp1 WRITE setMyProp1)
    QString myProp1() const { return m_myProp1; }
    Q_SLOT void setMyProp1(const QString &mt) { m_myProp1 = mt; }

    Q_PROPERTY(QString myProp2 READ myProp2 WRITE setMyProp2)
    QString myProp2() const { return m_myProp2; }
For faster browsing, not all history is shown. View entire blame