1 | //! [0]
|
---|
2 | class MyFirstTest: public QObject
|
---|
3 | {
|
---|
4 | Q_OBJECT
|
---|
5 | private slots:
|
---|
6 | void initTestCase()
|
---|
7 | { qDebug("called before everything else"); }
|
---|
8 | void myFirstTest()
|
---|
9 | { QVERIFY(1 == 1); }
|
---|
10 | void mySecondTest()
|
---|
11 | { QVERIFY(1 != 2); }
|
---|
12 | void cleanupTestCase()
|
---|
13 | { qDebug("called after myFirstTest and mySecondTest"); }
|
---|
14 | };
|
---|
15 | //! [0]
|
---|
16 |
|
---|
17 |
|
---|
18 | //! [1]
|
---|
19 | QT += testlib
|
---|
20 | //! [1]
|
---|
21 |
|
---|
22 |
|
---|
23 | //! [2]
|
---|
24 | testname [options] [testfunctions[:testdata]]...
|
---|
25 | //! [2]
|
---|
26 |
|
---|
27 |
|
---|
28 | //! [3]
|
---|
29 | /myTestDirectory$ testQString toUpper
|
---|
30 | //! [3]
|
---|
31 |
|
---|
32 |
|
---|
33 | //! [4]
|
---|
34 | /myTestDirectory$ testQString toUpper toInt:zero
|
---|
35 | //! [4]
|
---|
36 |
|
---|
37 |
|
---|
38 | //! [5]
|
---|
39 | /myTestDirectory$ testMyWidget -vs -eventdelay 500
|
---|
40 | //! [5]
|
---|
41 |
|
---|
42 |
|
---|
43 | //! [6]
|
---|
44 | cetest [options] ...
|
---|
45 | //! [6]
|
---|
46 |
|
---|
47 |
|
---|
48 | //! [7]
|
---|
49 | set INCLUDE=C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Inc;%INCLUDE%
|
---|
50 | set LIB=C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Lib;%LIB%
|
---|
51 | //! [7]
|
---|
52 |
|
---|
53 |
|
---|
54 | //! [8]
|
---|
55 | void TestQString::toUpper()
|
---|
56 | {
|
---|
57 | QString str = "Hello";
|
---|
58 | QVERIFY(str.toUpper() == "HELLO");
|
---|
59 | }
|
---|
60 | //! [8]
|
---|
61 |
|
---|
62 |
|
---|
63 | //! [9]
|
---|
64 | /myTestDirectory$ qmake -project "QT += testlib"
|
---|
65 | /myTestDirectory$ qmake
|
---|
66 | /myTestDirectory$ make
|
---|
67 | //! [9]
|
---|
68 |
|
---|
69 |
|
---|
70 | //! [10]
|
---|
71 | ********* Start testing of TestQString *********
|
---|
72 | Config: Using QTest library 4.5.1, Qt 4.5.1
|
---|
73 | PASS : TestQString::initTestCase()
|
---|
74 | PASS : TestQString::toUpper()
|
---|
75 | PASS : TestQString::cleanupTestCase()
|
---|
76 | Totals: 3 passed, 0 failed, 0 skipped
|
---|
77 | ********* Finished testing of TestQString *********
|
---|
78 | //! [10]
|
---|
79 |
|
---|
80 |
|
---|
81 | //! [11]
|
---|
82 | QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
|
---|
83 | QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
|
---|
84 | QCOMPARE(QString("HellO").toUpper(), QString("HELLO"));
|
---|
85 | QCOMPARE(QString("HELLO").toUpper(), QString("HELLO"));
|
---|
86 | //! [11]
|
---|
87 |
|
---|
88 | //! [12]
|
---|
89 | class MyFirstBenchmark: public QObject
|
---|
90 | {
|
---|
91 | Q_OBJECT
|
---|
92 | private slots:
|
---|
93 | void myFirstBenchmark()
|
---|
94 | {
|
---|
95 | QString string1;
|
---|
96 | QString string2;
|
---|
97 | QBENCHMARK {
|
---|
98 | string1.localeAwareCompare(string2);
|
---|
99 | }
|
---|
100 | }
|
---|
101 | };
|
---|
102 | //! [12]
|
---|