tst_dumpers.cpp 178 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Bill King's avatar
Bill King committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
Bill King's avatar
Bill King committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Bill King's avatar
Bill King committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Bill King's avatar
Bill King committed
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
** Alternatively, 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.
Bill King's avatar
Bill King committed
23
**
hjk's avatar
hjk committed
24
25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
Bill King's avatar
Bill King committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
Bill King's avatar
Bill King committed
29

hjk's avatar
hjk committed
30
#include "debuggerprotocol.h"
31
32
#include "watchdata.h"
#include "watchutils.h"
33

34
#include <cplusplus/CppRewriter.h>
35
36
#include <projectexplorer/abstractmsvctoolchain.h>
#include <utils/environment.h>
37

38
#include <QtTest>
39
#include "temporarydir.h"
40

41
42
43
44
45
46
#if  QT_VERSION >= 0x050000
#define MSKIP_SINGLE(x) QSKIP(x)
#else
#define MSKIP_SINGLE(x) QSKIP(x, SkipSingle)
#endif

47
using namespace Debugger;
48
using namespace Utils;
hjk's avatar
hjk committed
49
using namespace Internal;
50

51
52
static QByteArray noValue = "\001";

53
54
55
56
57
58
59
60
61
62
static QString toHex(const QString &str)
{
    QString encoded;
    foreach (const QChar c, str) {
        encoded += QString::fromLatin1("%1")
            .arg(c.unicode(), 2, 16, QLatin1Char('0'));
    }
    return encoded;
}

hjk's avatar
hjk committed
63
64
65
66
67
68
69
70
71

struct Context
{
    Context() : qtVersion(0) {}

    QByteArray nameSpace;
    int qtVersion;
};

hjk's avatar
hjk committed
72
73
struct Name
{
hjk's avatar
hjk committed
74
75
76
77
78
    Name() : name(noValue) {}
    Name(const char *str) : name(str) {}
    Name(const QByteArray &ba) : name(ba) {}

    bool matches(const QByteArray &actualName0, const Context &context) const
hjk's avatar
hjk committed
79
80
81
    {
        QByteArray actualName = actualName0;
        QByteArray expectedName = name;
hjk's avatar
hjk committed
82
        expectedName.replace("@Q", context.nameSpace + 'Q');
hjk's avatar
hjk committed
83
84
85
86
87
88
89
        return actualName == expectedName;
    }

    QByteArray name;
};

static Name nameFromIName(const QByteArray &iname)
hjk's avatar
hjk committed
90
91
{
    int pos = iname.lastIndexOf('.');
hjk's avatar
hjk committed
92
    return Name(pos == -1 ? iname : iname.mid(pos + 1));
hjk's avatar
hjk committed
93
94
95
96
97
98
99
100
}

static QByteArray parentIName(const QByteArray &iname)
{
    int pos = iname.lastIndexOf('.');
    return pos == -1 ? QByteArray() : iname.left(pos);
}

hjk's avatar
hjk committed
101
struct ValueBase
102
{
hjk's avatar
hjk committed
103
104
105
106
107
108
109
110
    ValueBase() : hasPtrSuffix(false), version(0) {}

    bool hasPtrSuffix;
    int version;
};

struct Value : public ValueBase
{
111
112
113
114
    Value() : value(QString::fromLatin1(noValue)) {}
    Value(const char *str) : value(QLatin1String(str)) {}
    Value(const QByteArray &ba) : value(QString::fromLatin1(ba.data(), ba.size())) {}
    Value(const QString &str) : value(str) {}
115

hjk's avatar
hjk committed
116
    bool matches(const QString &actualValue0, const Context &context) const
117
    {
118
        if (value == QString::fromLatin1(noValue))
119
            return true;
hjk's avatar
hjk committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133

        if (context.qtVersion) {
            if (version == 4) {
                if (context.qtVersion < 0x40000 || context.qtVersion >= 0x50000) {
                    //QWARN("Qt 4 specific case skipped");
                    return true;
                }
            } else if (version == 5) {
                if (context.qtVersion < 0x50000 || context.qtVersion >= 0x60000) {
                    //QWARN("Qt 5 specific case skipped");
                    return true;
                }
            }
        }
134
135
136
        QString actualValue = actualValue0;
        if (actualValue == QLatin1String(" "))
            actualValue.clear(); // FIXME: Remove later.
137
138
        QString expectedValue = value;
        expectedValue.replace(QLatin1Char('@'), QString::fromLatin1(context.nameSpace));
hjk's avatar
hjk committed
139

140
        if (hasPtrSuffix)
141
142
143
            return actualValue.startsWith(expectedValue + QLatin1String(" @0x"))
                || actualValue.startsWith(expectedValue + QLatin1String("@0x"));
        return actualValue == expectedValue;
144
145
    }

146
    QString value;
147
148
149
150
151
152
153
154
};

struct Pointer : Value
{
    Pointer() { hasPtrSuffix = true; }
    Pointer(const QByteArray &value) : Value(value) { hasPtrSuffix = true; }
};

hjk's avatar
hjk committed
155
156
157
158
159
160
161
162
163
164
struct Value4 : Value
{
    Value4(const QByteArray &value) : Value(value) { version = 4; }
};

struct Value5 : Value
{
    Value5(const QByteArray &value) : Value(value) { version = 5; }
};

165
166
struct Type
{
hjk's avatar
hjk committed
167
168
169
170
171
    Type() {}
    Type(const char *str) : type(str) {}
    Type(const QByteArray &ba) : type(ba) {}

    bool matches(const QByteArray &actualType0, const Context &context) const
172
    {
173
174
        QByteArray actualType =
            CPlusPlus::simplifySTLType(QString::fromLatin1(actualType0)).toLatin1();
175
176
177
        actualType.replace(' ', "");
        QByteArray expectedType = type;
        expectedType.replace(' ', "");
hjk's avatar
hjk committed
178
        expectedType.replace('@', context.nameSpace);
179
180
181
182
183
        return actualType == expectedType;
    }
    QByteArray type;
};

hjk's avatar
hjk committed
184
struct Check
185
186
187
{
    Check() {}

hjk's avatar
hjk committed
188
    Check(const QByteArray &iname, const Value &value, const Type &type)
hjk's avatar
hjk committed
189
190
191
192
        : iname(iname), expectedName(nameFromIName(iname)),
          expectedValue(value), expectedType(type)
    {}

hjk's avatar
hjk committed
193
    Check(const QByteArray &iname, const Name &name,
194
         const Value &value, const Type &type)
195
196
197
198
199
        : iname(iname), expectedName(name),
          expectedValue(value), expectedType(type)
    {}

    QByteArray iname;
hjk's avatar
hjk committed
200
    Name expectedName;
201
    Value expectedValue;
202
    Type expectedType;
203
204
};

hjk's avatar
hjk committed
205
struct CheckType : public Check
206
{
hjk's avatar
hjk committed
207
    CheckType(const QByteArray &iname, const Name &name,
208
         const Type &type)
209
210
        : Check(iname, name, noValue, type)
    {}
211

212
    CheckType(const QByteArray &iname, const Type &type)
hjk's avatar
hjk committed
213
214
215
216
        : Check(iname, noValue, type)
    {}
};

hjk's avatar
hjk committed
217
218
219
220
221
222
223
224
225
struct CheckPlain : public Check
{
    CheckPlain(const QByteArray &iname, const Name &name,
         const Type &type)
        : Check(iname, name, noValue, type)
    {}

};

hjk's avatar
hjk committed
226
struct Profile
hjk's avatar
hjk committed
227
228
229
230
{
    Profile(const QByteArray &contents) : contents(contents) {}

    QByteArray contents;
231
232
};

hjk's avatar
hjk committed
233

hjk's avatar
hjk committed
234
235
struct Cxx11Profile : public Profile
{
236
237
    //Cxx11Profile() : Profile("CONFIG += c++11") {}
    Cxx11Profile() : Profile("QMAKE_CXXFLAGS += -std=c++0x") {}
hjk's avatar
hjk committed
238
239
};

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
struct GdbVersion
{
    // Minimum and maximum are inclusive.
    GdbVersion(int minimum = 0, int maximum = 0)
    {
        if (minimum && !maximum)
            maximum = minimum;
        if (maximum == 0)
            maximum = INT_MAX;

        max = maximum;
        min = minimum;
    }
    int min;
    int max;
};

257
258
struct ForceC {};

hjk's avatar
hjk committed
259
260
261
262
263
264
struct CoreProfile {};
struct CorePrivateProfile {};
struct GuiProfile {};

struct DataBase
{
265
    DataBase() : useQt(false), forceC(false), neededGdbVersion() {}
hjk's avatar
hjk committed
266
267
268

    mutable bool useQt;
    mutable bool forceC;
269
    mutable GdbVersion neededGdbVersion;
hjk's avatar
hjk committed
270
271
272
};

class Data : public DataBase
273
{
hjk's avatar
hjk committed
274
275
public:
    Data() {}
hjk's avatar
hjk committed
276
    Data(const QByteArray &code) : code(code) {}
277

278
    Data(const QByteArray &includes, const QByteArray &code)
hjk's avatar
hjk committed
279
        : includes(includes), code(code)
hjk's avatar
hjk committed
280
    {}
281

282
283
284
285
286
287
    const Data &operator%(const Check &check) const
    {
        checks.insert("local." + check.iname, check);
        return *this;
    }

hjk's avatar
hjk committed
288
289
290
291
292
293
    const Data &operator%(const Profile &profile) const
    {
        profileExtra += profile.contents;
        return *this;
    }

294
295
296
297
298
299
    const Data &operator%(const GdbVersion &gdbVersion) const
    {
        neededGdbVersion = gdbVersion;
        return *this;
    }

hjk's avatar
hjk committed
300
301
302
303
304
305
306
307
308
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
    const Data &operator%(const CoreProfile &) const
    {
        profileExtra +=
            "CONFIG += QT\n"
            "QT += gui\n"
            "greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets\n";

        useQt = true;
        return *this;
    }

    const Data &operator%(const GuiProfile &) const
    {
        profileExtra +=
            "CONFIG += QT\n"
            "QT += gui\n"
            "greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets\n";

        useQt = true;
        return *this;
    }

    const Data &operator%(const CorePrivateProfile &) const
    {
        profileExtra +=
            "CONFIG += QT\n"
            "greaterThan(QT_MAJOR_VERSION, 4) {\n"
            "  QT += core core-private\n"
            "  CONFIG += no_private_qt_headers_warning\n"
            "}";

        useQt = true;
        return *this;
    }

335
336
337
338
339
340
    const Data &operator%(const ForceC &) const
    {
        forceC = true;
        return *this;
    }

hjk's avatar
hjk committed
341
public:
hjk's avatar
hjk committed
342
    mutable QByteArray profileExtra;
hjk's avatar
hjk committed
343
344
    QByteArray includes;
    QByteArray code;
hjk's avatar
hjk committed
345
    mutable QMap<QByteArray, Check> checks; // IName -> Action
hjk's avatar
hjk committed
346
347
};

348
349
350
351
352
353
354
355
356
357
358
359
360
361
struct TempStuff
{
    TempStuff() : buildTemp(QLatin1String("qt_tst_dumpers_"))
    {
        buildPath = buildTemp.path();
        buildTemp.setAutoRemove(false);
        QVERIFY(!buildPath.isEmpty());
    }

    QByteArray input;
    QTemporaryDir buildTemp;
    QString buildPath;
};

362
363
364
365
366
enum DebuggerEngine
{
    GdbEngine,
    CdbEngine,
    LldbEngine
367
368
};

hjk's avatar
hjk committed
369
Q_DECLARE_METATYPE(Data)
hjk's avatar
hjk committed
370

371
class tst_Dumpers : public QObject
372
373
374
375
{
    Q_OBJECT

public:
376
377
378
379
380
381
382
383
384
385
    tst_Dumpers()
    {
        t = 0;
        m_keepTemp = false;
        m_gdbVersion = 0;
        m_gdbBuildVersion = 0;
        m_lldbVersion = 0;
        m_isMacGdb = false;
        m_isQnxGdb = false;
    }
386
387

private slots:
hjk's avatar
hjk committed
388
    void initTestCase();
hjk's avatar
hjk committed
389
390
    void dumper();
    void dumper_data();
391
392
    void init();
    void cleanup();
hjk's avatar
hjk committed
393
394

private:
395
    TempStuff *t;
hjk's avatar
hjk committed
396
397
    QByteArray m_debuggerBinary;
    QByteArray m_qmakeBinary;
398
    QProcessEnvironment m_env;
hjk's avatar
hjk committed
399
    bool m_usePython;
400
    DebuggerEngine m_debuggerEngine;
hjk's avatar
hjk committed
401
    bool m_keepTemp;
402
403
    int m_gdbVersion; // 7.5.1 -> 70501
    int m_gdbBuildVersion;
404
    int m_lldbVersion;
405
406
    bool m_isMacGdb;
    bool m_isQnxGdb;
hjk's avatar
hjk committed
407
408
409
410
411
412
413
};

void tst_Dumpers::initTestCase()
{
    m_debuggerBinary = qgetenv("QTC_DEBUGGER_PATH");
    if (m_debuggerBinary.isEmpty())
        m_debuggerBinary = "gdb";
414
415
416
417
418
419

    m_debuggerEngine = GdbEngine;
    if (m_debuggerBinary.endsWith("cdb.exe"))
        m_debuggerEngine = CdbEngine;
    if (m_debuggerBinary.endsWith("lldb") || m_debuggerBinary.contains("/lldb-"))
        m_debuggerEngine = LldbEngine;
hjk's avatar
hjk committed
420
421
422
423
424

    m_qmakeBinary = qgetenv("QTC_QMAKE_PATH");
    if (m_qmakeBinary.isEmpty())
        m_qmakeBinary = "qmake";

425
    Environment utilsEnv = Environment::systemEnvironment();
426
427
    utilsEnv.appendOrSet(QLatin1String("QT_HASH_SEED"), QLatin1String("0"));

428
    if (m_debuggerEngine == GdbEngine) {
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
        QProcess debugger;
        debugger.start(QString::fromLatin1(m_debuggerBinary)
                       + QLatin1String(" -i mi -quiet -nx"));
        bool ok = debugger.waitForStarted();
        debugger.write("set confirm off\npython print 43\nshow version\nquit\n");
        ok = debugger.waitForFinished();
        QVERIFY(ok);
        QByteArray output = debugger.readAllStandardOutput();
        //qDebug() << "stdout: " << output;
        m_usePython = !output.contains("Python scripting is not supported in this copy of GDB");
        qDebug() << (m_usePython ? "Python is available" : "Python is not available");

        QString version = QString::fromLocal8Bit(output);
        int pos1 = version.indexOf(QLatin1String("&\"show version\\n"));
        QVERIFY(pos1 != -1);
        pos1 += 20;
        int pos2 = version.indexOf(QLatin1String("~\"Copyright (C) "), pos1);
        QVERIFY(pos2 != -1);
        pos2 -= 4;
        version = version.mid(pos1, pos2 - pos1);
449
        extractGdbVersion(version, &m_gdbVersion,
450
451
            &m_gdbBuildVersion, &m_isMacGdb, &m_isQnxGdb);
        qDebug() << "Gdb version " << m_gdbVersion;
452
    } else if (m_debuggerEngine == CdbEngine) {
453
454
455
        QByteArray envBat = qgetenv("QTC_MSVC_ENV_BAT");
        QMap <QString, QString> envPairs;
        QVERIFY(ProjectExplorer::Internal::AbstractMsvcToolChain::generateEnvironmentSettings(
456
                    utilsEnv, QString::fromLatin1(envBat), QString(), envPairs));
457
458
459
460
461
462
463
464
465

        for (QMap<QString,QString>::const_iterator envIt = envPairs.begin(); envIt!=envPairs.end(); ++envIt)
                utilsEnv.set(envIt.key(), envIt.value());

        const QByteArray cdbextPath = QByteArray(CDBEXT_PATH) + QByteArray("\\qtcreatorcdbext64");
        QVERIFY(QFile::exists(QString::fromLatin1(cdbextPath + QByteArray("\\qtcreatorcdbext.dll"))));
        utilsEnv.appendOrSet(QLatin1String("_NT_DEBUGGER_EXTENSION_PATH"),
                             QString::fromLatin1(cdbextPath),
                             QLatin1String(";"));
466
467
468
469
470
471
472
473
474
475
476
477
478
    } else if (m_debuggerEngine == LldbEngine) {
        m_usePython = true;
        QProcess debugger;
        debugger.start(QString::fromLatin1(m_debuggerBinary + " -v"));
        bool ok = debugger.waitForFinished(2000);
        QVERIFY(ok);
        QByteArray output = debugger.readAllStandardOutput();
        output += debugger.readAllStandardError();
        output = output.trimmed();
        // Should be something like LLDB-178
        m_lldbVersion = output.mid(5).toInt();
        qDebug() << "Lldb version " << output << m_lldbVersion;
        QVERIFY(m_lldbVersion);
479
480
    }
    m_env = utilsEnv.toProcessEnvironment();
hjk's avatar
hjk committed
481
482
}

483
void tst_Dumpers::init()
hjk's avatar
hjk committed
484
{
485
    t = new TempStuff();
hjk's avatar
hjk committed
486
487
}

488
void tst_Dumpers::cleanup()
hjk's avatar
hjk committed
489
{
490
491
    if (!t->buildTemp.autoRemove()) {
        QFile logger(t->buildPath + QLatin1String("/input.txt"));
hjk's avatar
hjk committed
492
        logger.open(QIODevice::ReadWrite);
493
        logger.write(t->input);
hjk's avatar
hjk committed
494
    }
495
496
    delete t;
}
497

hjk's avatar
hjk committed
498
499
500
501
void tst_Dumpers::dumper()
{
    QFETCH(Data, data);

502
    if (m_debuggerEngine == GdbEngine) {
503
504
505
506
507
        if (data.neededGdbVersion.min > m_gdbVersion)
            MSKIP_SINGLE("Need minimum GDB version " + QByteArray::number(data.neededGdbVersion.min));
        if (data.neededGdbVersion.max < m_gdbVersion)
            MSKIP_SINGLE("Need maximum GDB version " + QByteArray::number(data.neededGdbVersion.max));
    }
508

hjk's avatar
hjk committed
509
510
511
512
    QString cmd;
    QByteArray output;
    QByteArray error;

513
514
    const char *mainFile = data.forceC ? "main.c" : "main.cpp";

515
516
    QFile proFile(t->buildPath + QLatin1String("/doit.pro"));
    QVERIFY(proFile.open(QIODevice::ReadWrite));
517
518
519
    proFile.write("SOURCES = ");
    proFile.write(mainFile);
    proFile.write("\nTARGET = doit\n");
520
521
    proFile.write("\nCONFIG -= release\n");
    proFile.write("\nCONFIG += debug\n");
hjk's avatar
hjk committed
522
523
524
525
    if (data.useQt)
        proFile.write("QT -= widgets gui\n");
    else
        proFile.write("CONFIG -= QT\n");
hjk's avatar
hjk committed
526
    proFile.write(data.profileExtra);
hjk's avatar
hjk committed
527
528
    proFile.close();

529
530
    QFile source(t->buildPath + QLatin1Char('/') + QLatin1String(mainFile));
    QVERIFY(source.open(QIODevice::ReadWrite));
hjk's avatar
hjk committed
531
    QByteArray fullCode =
hjk's avatar
hjk committed
532
            "\n\nvoid unused(const void *first,...) { (void) first; }"
hjk's avatar
hjk committed
533
            "\n\nvoid breakHere() {}"
hjk's avatar
hjk committed
534
            "\n\n" + data.includes +
hjk's avatar
hjk committed
535
            "\n\nint main(int argc, char *argv[])"
hjk's avatar
hjk committed
536
            "\n{"
hjk's avatar
hjk committed
537
538
            "\n    int qtversion = " + (data.useQt ? "QT_VERSION" : "0") + ";\n"
            "\n    unused(&argc, &argv, &qtversion);\n"
hjk's avatar
hjk committed
539
540
            "\n" + data.code +
            "\n    breakHere();"
541
            "\n    return 0;"
hjk's avatar
hjk committed
542
543
            "\n}\n";
    source.write(fullCode);
hjk's avatar
hjk committed
544
545
546
    source.close();

    QProcess qmake;
547
    qmake.setWorkingDirectory(t->buildPath);
hjk's avatar
hjk committed
548
    cmd = QString::fromLatin1(m_qmakeBinary);
hjk's avatar
hjk committed
549
550
    //qDebug() << "Starting qmake: " << cmd;
    qmake.start(cmd);
551
    QVERIFY(qmake.waitForFinished());
hjk's avatar
hjk committed
552
553
554
    output = qmake.readAllStandardOutput();
    error = qmake.readAllStandardError();
    //qDebug() << "stdout: " << output;
555
    if (!error.isEmpty()) { qDebug() << error; QVERIFY(false); }
hjk's avatar
hjk committed
556
557

    QProcess make;
558
    make.setWorkingDirectory(t->buildPath);
559
    cmd = m_debuggerEngine == GdbEngine ? QString::fromLatin1("make")
560
                                        : QString::fromLatin1("nmake");
hjk's avatar
hjk committed
561
562
    //qDebug() << "Starting make: " << cmd;
    make.start(cmd);
563
    QVERIFY(make.waitForFinished());
hjk's avatar
hjk committed
564
565
566
    output = make.readAllStandardOutput();
    error = make.readAllStandardError();
    //qDebug() << "stdout: " << output;
567
    if (make.exitCode()) {
hjk's avatar
hjk committed
568
569
570
571
572
573
        qDebug() << error;
        qDebug() << "\n------------------ CODE --------------------";
        qDebug() << fullCode;
        qDebug() << "\n------------------ CODE --------------------";
        qDebug() << ".pro: " << qPrintable(proFile.fileName());
    }
hjk's avatar
hjk committed
574
575
576

    QByteArray dumperDir = DUMPERDIR;

577
578
579
    QSet<QByteArray> expandedINames;
    expandedINames.insert("local");
    foreach (const Check &check, data.checks) {
hjk's avatar
hjk committed
580
581
582
583
584
585
586
        QByteArray parent = check.iname;
        while (true) {
            parent = parentIName(parent);
            if (parent.isEmpty())
                break;
            expandedINames.insert("local." + parent);
        }
587
588
589
590
591
592
593
594
595
    }

    QByteArray expanded;
    foreach (const QByteArray &iname, expandedINames) {
        if (!expanded.isEmpty())
            expanded.append(',');
        expanded += iname;
    }

596
597
598
    QByteArray cmds;
    QStringList args;

599
    if (m_debuggerEngine == GdbEngine) {
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
        args << QLatin1String("-i")
             << QLatin1String("mi")
             << QLatin1String("-quiet")
             << QLatin1String("-nx");
        QByteArray nograb = "-nograb";

        cmds = "set confirm off\n"
                "file doit\n"
                "break breakHere\n"
                "set print object on\n"
                "set auto-load python-scripts no\n";

        if (m_usePython) {
            cmds +=
                    "python execfile('" + dumperDir + "/bridge.py')\n"
                    "python execfile('" + dumperDir + "/dumper.py')\n"
                    "python execfile('" + dumperDir + "/qttypes.py')\n"
                    "bbsetup\n"
                    "run " + nograb + "\n"
                    "up\n"
                    "python print('@%sS@%s@' % ('N', qtNamespace()))\n"
                    "bb options:fancy,autoderef,dyntype vars: expanded:" + expanded + " typeformats:\n";
        } else {
            cmds += "run\n";
            foreach (const Check &check, data.checks) {
                QByteArray iname = check.iname;
                //qDebug() << "INAME: " << iname;
                cmds += "-var-create " + iname + " * "
                        + check.expectedName.name + "\n";
            }
hjk's avatar
hjk committed
630
        }
631
        cmds += "quit\n";
ck's avatar
ck committed
632

633
    } else if (m_debuggerEngine == CdbEngine) {
634
635
636
637
638
639
640
641
642
643
644
645
        args << QLatin1String("-aqtcreatorcdbext.dll")
             << QLatin1String("-lines")
             << QLatin1String("-G")
             << QLatin1String("-c.idle_cmd")
             << QLatin1String("!qtcreatorcdbext.idle")
             << QLatin1String("debug\\doit.exe");
        cmds = "l+t\n"
               "l+s\n"
               "bu `doit!" + source.fileName().toLatin1() + ":5`\n"
               "sxi 0x4000001f\n"
               "g\n"
               "gu\n"
646
647
648
649
650
651
652
653
654
               "!qtcreatorcdbext.expandlocals -t 0 -c 0 " + expanded + "\n";
        int token = 0;
        QStringList sortediNames;
        foreach (QByteArray iName, expandedINames)
            sortediNames << QString::fromLatin1(iName);
        sortediNames.sort();
        foreach (QString iName, sortediNames)
            cmds += "!qtcreatorcdbext.locals -t " + QByteArray::number(++token) + " -c 0 " + iName.toLatin1() + "\n";
        cmds += "q\n";
655
656
657
658
659
660
661
662
663
664
    } else if (m_debuggerEngine == LldbEngine) {
        cmds = "script execfile('" + dumperDir + "/bridge.py')\n"
               "script execfile('" + dumperDir + "/dumper.py')\n"
               "script execfile('" + dumperDir + "/qttypes.py')\n"
               "bbsetup\n"
               "run\n"
               "up\n"
               "script print('@%sS@%s@' % ('N', qtNamespace()))\n"
               "script bb('options:fancy,autoderef,dyntype vars: expanded:" + expanded + " typeformats:')\n"
               "quit\n";
665
    }
hjk's avatar
hjk committed
666

667
    t->input = cmds;
hjk's avatar
hjk committed
668

hjk's avatar
hjk committed
669
    QProcess debugger;
670
    debugger.setProcessEnvironment(m_env);
671
    debugger.setWorkingDirectory(t->buildPath);
672
    debugger.start(QString::fromLatin1(m_debuggerBinary), args);
673
    QVERIFY(debugger.waitForStarted());
hjk's avatar
hjk committed
674
    debugger.write(cmds);
675
    QVERIFY(debugger.waitForFinished());
hjk's avatar
hjk committed
676
677
678
679
680
    output = debugger.readAllStandardOutput();
    //qDebug() << "stdout: " << output;
    error = debugger.readAllStandardError();
    if (!error.isEmpty()) { qDebug() << error; }

hjk's avatar
hjk committed
681
    if (m_keepTemp) {
682
683
        QFile logger(t->buildPath + QLatin1String("/output.txt"));
        logger.open(QIODevice::ReadWrite);
hjk's avatar
hjk committed
684
685
686
687
        logger.write("=== STDOUT ===\n");
        logger.write(output);
        logger.write("\n=== STDERR ===\n");
        logger.write(error);
ck's avatar
ck committed
688
689
    }

hjk's avatar
hjk committed
690
    Context context;
691
    QByteArray contents;
692
    if (m_debuggerEngine == GdbEngine) {
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
        int posDataStart = output.indexOf("data=");
        QVERIFY(posDataStart != -1);
        int posDataEnd = output.indexOf(",typeinfo", posDataStart);
        QVERIFY(posDataEnd != -1);
        contents = output.mid(posDataStart, posDataEnd - posDataStart);

        int posNameSpaceStart = output.indexOf("@NS@");
        QVERIFY(posNameSpaceStart != -1);
        posNameSpaceStart += sizeof("@NS@") - 1;
        int posNameSpaceEnd = output.indexOf("@", posNameSpaceStart);
        QVERIFY(posNameSpaceEnd != -1);
        context.nameSpace = output.mid(posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart);
        //qDebug() << "FOUND NS: " << context.nameSpace;
        if (context.nameSpace == "::")
            context.nameSpace.clear();
        contents.replace("\\\"", "\"");
    } else {
        const QByteArray locals = "|locals|";
        int pos1 = output.indexOf(locals);
        QVERIFY(pos1 != -1);
        do {
714
715
716
            pos1 += locals.length();
            if (output.at(pos1) == '[')
                ++pos1;
717
718
            int pos2 = output.indexOf("\n", pos1);
            QVERIFY(pos2 != -1);
719
720
            if (output.at(pos2 - 1) == ']')
                --pos2;
721
722
723
724
            contents += output.mid(pos1, pos2 - pos1);
            pos1 = output.indexOf(locals, pos2);
        } while (pos1 != -1);
    }
hjk's avatar
hjk committed
725
726

    GdbMi actual;
727
    actual.fromStringMultiple(contents);
728
729
730
731
    WatchData local;
    local.iname = "local";

    QList<WatchData> list;
hjk's avatar
hjk committed
732
    foreach (const GdbMi &child, actual.children()) {
733
734
735
        WatchData dummy;
        dummy.iname = child.findChild("iname").data();
        dummy.name = QLatin1String(child.findChild("name").data());
hjk's avatar
hjk committed
736
737
738
739
        if (dummy.iname == "local.qtversion")
            context.qtVersion = child.findChild("value").data().toInt();
        else
            parseWatchData(expandedINames, dummy, child, &list);
740
741
    }

hjk's avatar
hjk committed
742
    //qDebug() << "QT VERSION " << QByteArray::number(context.qtVersion, 16);
hjk's avatar
hjk committed
743
    QSet<QByteArray> seenINames;
744
    bool ok = true;
745
    foreach (const WatchData &item, list) {
hjk's avatar
hjk committed
746
        seenINames.insert(item.iname);
747
748
        if (data.checks.contains(item.iname)) {
            Check check = data.checks.take(item.iname);
hjk's avatar
hjk committed
749
            if (!check.expectedName.matches(item.name.toLatin1(), context)) {
hjk's avatar
hjk committed
750
                qDebug() << "INAME        : " << item.iname;
hjk's avatar
hjk committed
751
752
                qDebug() << "NAME ACTUAL  : " << item.name.toLatin1();
                qDebug() << "NAME EXPECTED: " << check.expectedName.name;
753
                ok = false;
ck's avatar
ck committed
754
            }
hjk's avatar
hjk committed
755
            if (!check.expectedValue.matches(item.value, context)) {
hjk's avatar
hjk committed
756
                qDebug() << "INAME         : " << item.iname;
757
758
                qDebug() << "VALUE ACTUAL  : " << item.value << toHex(item.value);
                qDebug() << "VALUE EXPECTED: " << check.expectedValue.value << toHex(check.expectedValue.value);
759
                ok = false;
ck's avatar
ck committed
760
            }
hjk's avatar
hjk committed
761
            if (!check.expectedType.matches(item.type, context)) {
hjk's avatar
hjk committed
762
                qDebug() << "INAME        : " << item.iname;
763
                qDebug() << "TYPE ACTUAL  : " << item.type;
764
                qDebug() << "TYPE EXPECTED: " << check.expectedType.type;
765
                ok = false;
766
            }
ck's avatar
ck committed
767
768
        }
    }
769
770

    if (!data.checks.isEmpty()) {
hjk's avatar
hjk committed
771
        bool fail = false;
772
        qDebug() << "SOME TESTS NOT EXECUTED: ";
hjk's avatar
hjk committed
773
        foreach (const Check &check, data.checks) {
774
            qDebug() << "  TEST NOT FOUND FOR INAME: " << check.iname;
hjk's avatar
hjk committed
775
776
777
            if (!fail && check.expectedValue.version != 0)
                fail = true;
        }
hjk's avatar
hjk committed
778
        qDebug() << "SEEN INAMES " << seenINames;
hjk's avatar
hjk committed
779
        qDebug() << "EXPANDED     : " << expanded;
780
        ok = false;
781
    }
782
783
    if (!ok)
        qDebug() << "CONTENTS     : " << contents;
784
785
    QVERIFY(ok);
    t->buildTemp.setAutoRemove(m_keepTemp);
ck's avatar
ck committed
786
787
}

hjk's avatar
hjk committed
788
void tst_Dumpers::dumper_data()
ck's avatar
ck committed
789
{
hjk's avatar
hjk committed
790
    QTest::addColumn<Data>("data");
ck's avatar
ck committed
791

hjk's avatar
hjk committed
792
    QByteArray fooData =
hjk's avatar
hjk committed
793
            "#include <QHash>\n"
hjk's avatar
hjk committed
794
            "#include <QMap>\n"
hjk's avatar
hjk committed
795
796
            "#include <QObject>\n"
            "#include <QString>\n"
hjk's avatar
hjk committed
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
            "class Foo\n"
            "{\n"
            "public:\n"
            "    Foo(int i = 0)\n"
            "        : a(i), b(2)\n"
            "    {}\n"
            "    virtual ~Foo()\n"
            "    {\n"
            "        a = 5;\n"
            "    }\n"
            "    void doit()\n"
            "    {\n"
            "        static QObject ob;\n"
            "        m[\"1\"] = \"2\";\n"
            "        h[&ob] = m.begin();\n"
            "        --b;\n"
            "    }\n"
            "public:\n"
            "    int a, b;\n"
            "    char x[6];\n"
            "private:\n"
            "    typedef QMap<QString, QString> Map;\n"
            "    Map m;\n"
            "    QHash<QObject *, Map::iterator> h;\n"
hjk's avatar
hjk committed
821
822
823
824
825
826
827
828
829
830
831
832
            "};\n";

    QByteArray nsData =
            "namespace nsA {\n"
            "namespace nsB {\n"
           " struct SomeType\n"
           " {\n"
           "     SomeType(int a) : a(a) {}\n"
           "     int a;\n"
           " };\n"
           " } // namespace nsB\n"
           " } // namespace nsA\n";
833
834

    QTest::newRow("AnonymousStruct")
835
836
837
838
839
840
            << Data("union {\n"
                    "     struct { int i; int b; };\n"
                    "     struct { float f; };\n"
                    "     double d;\n"
                    " } a = { { 42, 43 } };\n (void)a;")
               % CheckType("a", "a", "union {...}")
hjk's avatar
hjk committed
841
842
843
844
               % Check("a.b", "43", "int")
               % Check("a.d", "9.1245819032257467e-313", "double")
               % Check("a.f", "5.88545355e-44", "float")
               % Check("a.i", "42", "int");
845
846

    QTest::newRow("QByteArray0")
hjk's avatar
hjk committed
847
848
            << Data("#include <QByteArray>\n",
                    "QByteArray ba;")
hjk's avatar
hjk committed
849
               % CoreProfile()
hjk's avatar
hjk committed
850
               % Check("ba", "ba", "\"\"", "@QByteArray");
851
852

    QTest::newRow("QByteArray1")
hjk's avatar
hjk committed
853
854
            << Data("#include <QByteArray>\n",
                    "QByteArray ba = \"Hello\\\"World\";\n"
855
856
857
                    "ba += char(0);\n"
                    "ba += 1;\n"
                    "ba += 2;\n")
hjk's avatar
hjk committed
858
               % CoreProfile()
859
860
               % Check("ba", QByteArray("\"Hello\"World")
                       + char(0) + char(1) + char(2) + '"', "@QByteArray")
hjk's avatar
hjk committed
861
862
863
864
               % Check("ba.0", "[0]", "72", "char")
               % Check("ba.11", "[11]", "0", "char")
               % Check("ba.12", "[12]", "1", "char")
               % Check("ba.13", "[13]", "2", "char");
865
866

    QTest::newRow("QByteArray2")
hjk's avatar
hjk committed
867
868
869
            << Data("#include <QByteArray>\n"
                    "#include <QString>\n"
                    "#include <string>\n",
hjk's avatar
hjk committed
870
                    "QByteArray ba;\n"
871
872
873
                    "for (int i = 256; --i >= 0; )\n"
                    "    ba.append(char(i));\n"
                    "QString s(10000, 'x');\n"
hjk's avatar
hjk committed
874
                    "std::string ss(10000, 'c');\n"
hjk's avatar
hjk committed
875
                    "unused(&ba, &s, &ss);\n")
hjk's avatar
hjk committed
876
               % CoreProfile()
hjk's avatar
hjk committed
877
878
879
               % CheckType("ba", "@QByteArray")
               % Check("s", '"' + QByteArray(10000, 'x') + '"', "@QString")
               % Check("ss", '"' + QByteArray(10000, 'c') + '"', "std::string");
880
881

    QTest::newRow("QByteArray3")
hjk's avatar
hjk committed
882
883
            << Data("#include <QByteArray>\n",
                    "const char *str1 = \"\356\";\n"
884
885
886
887
                    "const char *str2 = \"\xee\";\n"
                    "const char *str3 = \"\\ee\";\n"
                    "QByteArray buf1(str1);\n"
                    "QByteArray buf2(str2);\n"
hjk's avatar
hjk committed
888
                    "QByteArray buf3(str3);\n"
hjk's avatar
hjk committed
889
                    "unused(&buf1, &buf2, &buf3);\n")
hjk's avatar
hjk committed
890
               % CoreProfile()
891
892
893
               % Check("buf1", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
               % Check("buf2", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
               % Check("buf3", "\"\\ee\"", "@QByteArray")
hjk's avatar
hjk committed
894
               % CheckType("str1", "char *");
895
896

    QTest::newRow("QByteArray4")
hjk's avatar
hjk committed
897
898
            << Data("#include <QByteArray>\n",
                    "char data[] = { 'H', 'e', 'l', 'l', 'o' };\n"
899
900
                    "QByteArray ba1 = QByteArray::fromRawData(data, 4);\n"
                    "QByteArray ba2 = QByteArray::fromRawData(data + 1, 4);\n")
hjk's avatar
hjk committed
901
               % CoreProfile()
hjk's avatar
hjk committed
902
903
               % Check("ba1", "\"Hell\"", "@QByteArray")
               % Check("ba2", "\"ello\"", "@QByteArray");
904
905

    QTest::newRow("QDate0")
hjk's avatar
hjk committed
906
            << Data("#include <QDate>\n",
hjk's avatar
hjk committed
907
                    "QDate date;\n"
hjk's avatar
hjk committed
908
                    "unused(&date);\n")
hjk's avatar
hjk committed
909
910
911
               % CoreProfile()
               % Check("date", Value4("(invalid)"), "@QDate")
               % Check("date", Value5(""), "@QDate");
912
913

    QTest::newRow("QDate1")
hjk's avatar
hjk committed
914
915
            << Data("#include <QDate>\n",
                    "QDate date;\n"
hjk's avatar
hjk committed
916
                    "date.setDate(1980, 1, 1);\n"
hjk's avatar
hjk committed
917
                    "unused(&date);\n")
hjk's avatar
hjk committed
918
               % CoreProfile()
919
               % Check("date", "Tue Jan 1 1980", "@QDate")
hjk's avatar
hjk committed
920
921
922
923
               % Check("date.(ISO)", "\"1980-01-01\"", "@QString")
               % CheckType("date.(Locale)", "@QString")
               % CheckType("date.(SystemLocale)", "@QString")
               % Check("date.toString", "\"Tue Jan 1 1980\"", "@QString");
924
925

    QTest::newRow("QTime0")
hjk's avatar
hjk committed
926
927
            << Data("#include <QTime>\n",
                    "QTime time;\n")
hjk's avatar
hjk committed
928
               % CoreProfile()
929
               % Check("time", "(invalid)", "@QTime");
930
931

    QTest::newRow("QTime1")
hjk's avatar
hjk committed
932
933
            << Data("#include <QTime>\n",
                    "QTime time(13, 15, 32);")
hjk's avatar
hjk committed
934
               % CoreProfile()
hjk's avatar
hjk committed
935
936
937
938
939
               % Check("time", "13:15:32", "@QTime")
               % Check("time.(ISO)", "\"13:15:32\"", "@QString")
               % CheckType("time.(Locale)", "@QString")
               % CheckType("time.(SystemLocale)", "@QString")
               % Check("time.toString", "\"13:15:32\"", "@QString");
940

941
    QTest::newRow("QDateTime0")
hjk's avatar
hjk committed
942
943
            << Data("#include <QDateTime>\n",
                    "QDateTime date;\n")
hjk's avatar
hjk committed
944
               % CoreProfile()
945
946
947
948
949
               % Check("date", "(invalid)", "@QDateTime");

    QTest::newRow("QDateTime1")
            << Data("#include <QDateTime>\n",
                    "QDateTime date(QDate(1980, 1, 1), QTime(13, 15, 32), Qt::UTC);\n")
hjk's avatar
hjk committed
950
               % CoreProfile()
951
952
953
954
955
956
               % Check("date", "Tue Jan 1 13:15:32 1980", "@QDateTime")
               % Check("date.(ISO)", "\"1980-01-01T13:15:32Z\"", "@QString")
               % CheckType("date.(Locale)", "@QString")
               % CheckType("date.(SystemLocale)", "@QString")
               % Check("date.toString", "\"Tue Jan 1 13:15:32 1980\"", "@QString")
               % Check("date.toUTC", "Tue Jan 1 13:15:32 1980", "@QDateTime");
957
958

#ifdef Q_OS_WIN
hjk's avatar
hjk committed
959
    QByteArray tempDir = "\"C:/Program Files\"";
960
#else
hjk's avatar
hjk committed
961
    QByteArray tempDir = "\"/tmp\"";
962
#endif
hjk's avatar
hjk committed
963
964
965
966
967
    QTest::newRow("QDir")
            << Data("#include <QDir>\n",
                    "QDir dir(" + tempDir + ");\n"
                    "QString s = dir.absolutePath();\n"
                    "unused(&dir, &s);\n")
hjk's avatar
hjk committed
968
               % CoreProfile()
hjk's avatar
hjk committed
969
970
971
               % Check("dir", tempDir, "@QDir")
               % Check("dir.absolutePath", tempDir, "@QString")
               % Check("dir.canonicalPath", tempDir, "@QString");
972
973
974

    QTest::newRow("QFileInfo")
#ifdef Q_OS_WIN
hjk's avatar
hjk committed
975
976
977
            << Data("#include <QFile>\n"
                    "#include <QFileInfo>\n",
                    "QFile file(\"C:\\\\Program Files\\t\");\n"
978
979
980
                    "file.setObjectName(\"A QFile instance\");\n"
                    "QFileInfo fi(\"C:\\Program Files\\tt\");\n"
                    "QString s = fi.absoluteFilePath();\n")
hjk's avatar
hjk committed
981
               % Check("fi", "\"C:/Program Files/tt\"", "QFileInfo")
982
               % Check("file", "\"C:\\Program Files\\t\"", "QFile")
hjk's avatar
hjk committed
983
               % Check("s", "\"C:/Program Files/tt\"", "QString");
984
#else
hjk's avatar
hjk committed
985
986
987
            << Data("#include <QFile>\n"
                    "#include <QFileInfo>\n",
                    "QFile file(\"/tmp/t\");\n"
988
989
990
                    "file.setObjectName(\"A QFile instance\");\n"
                    "QFileInfo fi(\"/tmp/tt\");\n"
                    "QString s = fi.absoluteFilePath();\n")
hjk's avatar
hjk committed
991
               % CoreProfile()
hjk's avatar
hjk committed
992
993
994
               % Check("fi", "\"/tmp/tt\"", "@QFileInfo")
               % Check("file", "\"/tmp/t\"", "@QFile")
               % Check("s", "\"/tmp/tt\"", "@QString");
995
996
997
#endif

    QTest::newRow("QHash1")
hjk's avatar
hjk committed
998
999
1000
            << Data("#include <QHash>\n"
                    "#include <QString>\n"
                    "#include <QList>\n",
hjk's avatar
hjk committed
1001
                    "QHash<QString, QList<int> > hash;\n"
1002
1003
1004
                    "hash.insert(\"Hallo\", QList<int>());\n"
                    "hash.insert(\"Welt\", QList<int>() << 1);\n"
                    "hash.insert(\"!\", QList<int>() << 1 << 2);\n")
hjk's avatar
hjk committed
1005
               % CoreProfile()
hjk's avatar
hjk committed
1006
1007
               % Check("hash", "<3 items>", "@QHash<@QString, @QList<int> >")
               % Check("hash.0", "[0]", "", "@QHashNode<@QString, @QList<int>>")
hjk's avatar
hjk committed
1008
1009
1010
1011
               % Check("hash.0.key", Value4("\"Hallo\""), "@QString")
               % Check("hash.0.key", Value5("\"Welt\""), "@QString")
               % Check("hash.0.value", Value4("<0 items>"), "@QList<int>")
               % Check("hash.0.value", Value5("<1 items>"), "@QList<int>")
hjk's avatar
hjk committed
1012
               % Check("hash.1", "[1]", "", "@QHashNode<@QString, @QList<int>>")
hjk's avatar
hjk committed
1013
1014
1015
1016
               % Check("hash.1.key", "key", Value4("\"Welt\""), "@QString")
               % Check("hash.1.key", "key", Value5("\"Hallo\""), "@QString")
               % Check("hash.1.value", "value", Value4("<1 items>"), "@QList<int>")
               % Check("hash.1.value", "value", Value5("<0 items>"), "@QList<int>")
hjk's avatar
hjk committed
1017
1018
1019
               % Check("hash.2", "[2]", "", "@QHashNode<@QString, @QList<int>>")
               % Check("hash.2.key", "key", "\"!\"", "@QString")
               % Check("hash.2.value", "value", "<2 items>", "@QList<int>")
hjk's avatar
hjk committed
1020
1021
               % Check("hash.2.value.0", "[0]", "1", "int")
               % Check("hash.2.value.1", "[1]", "2", "int");
1022
1023

    QTest::newRow("QHash2")
hjk's avatar
hjk committed
1024
1025
            << Data("#include <QHash>\n",
                    "QHash<int, float> hash;\n"
1026
1027
                    "hash[11] = 11.0;\n"
                    "hash[22] = 22.0;\n")
hjk's avatar
hjk committed
1028
               % CoreProfile()
hjk's avatar
hjk committed
1029
1030
1031
               % Check("hash", "hash", "<2 items>", "@QHash<int, float>")
               % Check("hash.22", "[22]", "22", "float")
               % Check("hash.11", "[11]", "11", "float");
1032
1033

    QTest::newRow("QHash3")
hjk's avatar
hjk committed
1034
1035
            << Data("#include <QString>\n"
                    "#include <QHash>\n",
hjk's avatar
hjk committed
1036
                    "QHash<QString, int> hash;\n"
1037
1038
1039
1040
1041
1042
1043
1044
1045
                    "hash[\"22.0\"] = 22.0;\n"
                    "hash[\"123.0\"] = 22.0;\n"
                    "hash[\"111111ss111128.0\"] = 28.0;\n"
                    "hash[\"11124.0\"] = 22.0;\n"
                    "hash[\"1111125.0\"] = 22.0;\n"
                    "hash[\"11111126.0\"] = 22.0;\n"
                    "hash[\"111111127.0\"] = 27.0;\n"
                    "hash[\"111111111128.0\"] = 28.0;\n"
                    "hash[\"111111111111111111129.0\"] = 29.0;\n")
hjk's avatar
hjk committed
1046
               % CoreProfile()
hjk's avatar
hjk committed
1047
1048
               % Check("hash", "hash", "<9 items>", "@QHash<@QString, int>")
               % Check("hash.0", "[0]", "", "@QHashNode<@QString, int>")
hjk's avatar
hjk committed
1049
1050
1051
1052
               % Check("hash.0.key", "key", Value4("\"123.0\""), "@QString")
               % Check("hash.0.key", "key", Value5("\"111111111128.0\""), "@QString")
               % Check("hash.0.value", Value4("22"), "int")
               % Check("hash.0.value", Value5("28"), "int")
hjk's avatar
hjk committed
1053
               % Check("hash.8", "[8]", "", "@QHashNode<@QString, int>")
hjk's avatar
hjk committed
1054
1055
1056
1057
               % Check("hash.8.key", "key", Value4("\"11124.0\""), "@QString")
               % Check("hash.8.key", "key", Value5("\"123.0\""), "@QString")
               % Check("hash.8.value", "value", Value4("22"), "int")
               % Check("hash.8.value", "value", Value5("22"), "int");
1058
1059

    QTest::newRow("QHash4")
hjk's avatar
hjk committed
1060
1061
            << Data("#include <QByteArray>\n"
                    "#include <QHash>\n",
hjk's avatar
hjk committed
1062
                    "QHash<QByteArray, float> hash;\n"
1063
1064
1065
1066
1067
1068
1069
1070
1071
                    "hash[\"22.0\"] = 22.0;\n"
                    "hash[\"123.0\"] = 22.0;\n"
                    "hash[\"111111ss111128.0\"] = 28.0;\n"
                    "hash[\"11124.0\"] = 22.0;\n"
                    "hash[\"1111125.0\"] = 22.0;\n"
                    "hash[\"11111126.0\"] = 22.0;\n"
                    "hash[\"111111127.0\"] = 27.0;\n"
                    "hash[\"111111111128.0\"] = 28.0;\n"
                    "hash[\"111111111111111111129.0\"] = 29.0;\n")
hjk's avatar
hjk committed
1072
               % CoreProfile()
hjk's avatar
hjk committed
1073
               % Check("hash", "<9 items>", "@QHash<@QByteArray, float>")
hjk's avatar
hjk committed
1074
               % Check("hash.0", "[0]", "", "@QHashNode<@QByteArray, float>")