~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to projectmanagers/cmake/tests/cmakeast_test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "cmakeast_test.h"
 
2
 
 
3
#include "cmakeast.h"
 
4
#include "cmakelistsparser.h"
 
5
#include <astfactory.h>
 
6
 
 
7
QTEST_MAIN( CMakeAstTest )
 
8
 
 
9
void CMakeAstTest::testAddExecutableGoodParse()
 
10
{
 
11
    QFETCH( CMakeFunctionDesc, function );
 
12
    CMakeAst* ast = AstFactory::self()->createAst("add_executable");
 
13
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
14
    delete ast;
 
15
}
 
16
 
 
17
void CMakeAstTest::testAddExecutableGoodParse_data()
 
18
{
 
19
    CMakeFunctionDesc func;
 
20
    func.name = "add_executable";
 
21
    QStringList argList;
 
22
    argList << "foo" << "bar.c";
 
23
    func.addArguments( argList );
 
24
 
 
25
    CMakeFunctionDesc func2;
 
26
    func2.name = "add_executable";
 
27
    QStringList argList2;
 
28
    argList2 << "foo" << "WIN32" << "${mysrcs_SRCS}";
 
29
    func2.addArguments( argList2 );
 
30
 
 
31
    CMakeFunctionDesc func3;
 
32
    func3.name = "ADD_EXECUTABLE";
 
33
    QStringList argList3;
 
34
    argList3 << "foo" << "MACOSX_BUNDLE" << "${mysrcs_SRCS}";
 
35
    func3.addArguments( argList3 );
 
36
 
 
37
    CMakeFunctionDesc func4;
 
38
    func4.name = "add_executable";
 
39
    QStringList argList4;
 
40
    argList4 << "foo" << "EXCLUDE_FROM_ALL" << "${mysrcs_SRCS}";
 
41
    func4.addArguments( argList4 );
 
42
 
 
43
    CMakeFunctionDesc func5;
 
44
    func5.name = "add_executable";
 
45
    QStringList argList5;
 
46
    argList5 << "foo" << "WIN32" << "MACOSX_BUNDLE" << "EXCLUDE_FROM_ALL"
 
47
             << "${mysrcs_SRCS}";
 
48
    func5.addArguments( argList5 );
 
49
    
 
50
    CMakeFunctionDesc func6;
 
51
    func5.name = "add_executable";
 
52
    QStringList argList6=QString("KDE4__kconfig_compiler IMPORTED").split(' ');
 
53
    func5.addArguments( argList6 );
 
54
 
 
55
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
56
    QTest::newRow( "only sources" ) << func;
 
57
    QTest::newRow( "win 32 app" ) << func2;
 
58
    QTest::newRow( "mac os bundle" ) << func3;
 
59
    QTest::newRow( "exclude from all" ) << func4;
 
60
    QTest::newRow( "all" ) << func5;
 
61
}
 
62
 
 
63
void CMakeAstTest::testAddExecutableBadParse()
 
64
{
 
65
    QFETCH( CMakeFunctionDesc, function );
 
66
    CMakeAst* ast = AstFactory::self()->createAst("add_executable");
 
67
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
68
    delete ast;
 
69
}
 
70
 
 
71
void CMakeAstTest::testAddExecutableBadParse_data()
 
72
{
 
73
    CMakeFunctionDesc func;
 
74
    func.name = "add_executable";
 
75
    QStringList argList;
 
76
    argList << "foo";
 
77
    func.addArguments( argList );
 
78
 
 
79
    CMakeFunctionDesc func2;
 
80
    func2.name = "addexecutable";
 
81
    QStringList argList2;
 
82
    argList2 << "foo" << "${mysrcs_SRCS}";
 
83
    func2.addArguments( argList2 );
 
84
 
 
85
    CMakeFunctionDesc func3;
 
86
    func3.name = "add_executable";
 
87
    QStringList argList3;
 
88
    func3.addArguments( argList3 );
 
89
 
 
90
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
91
    QTest::newRow( "no sources" ) << func;
 
92
    QTest::newRow( "wrong name" ) << func2;
 
93
    QTest::newRow( "no arguments" ) << func3;
 
94
 
 
95
}
 
96
 
 
97
 
 
98
 
 
99
 
 
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
 
 
106
void CMakeAstTest::testAddLibraryGoodParse()
 
107
{
 
108
    QFETCH( CMakeFunctionDesc, function );
 
109
    CMakeAst* ast = AstFactory::self()->createAst("add_library");
 
110
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
111
    delete ast;
 
112
}
 
113
 
 
114
void CMakeAstTest::testAddLibraryGoodParse_data()
 
115
{
 
116
    CMakeFunctionDesc func, func2, func3, func4, func5;
 
117
    QStringList argList, argList2, argList3, argList4;
 
118
 
 
119
    func.name = func2.name = func3.name = func4.name = func5.name =  "add_library";
 
120
    argList << "foo" << "${SRCS}";
 
121
    func.addArguments( argList );
 
122
 
 
123
    argList2 << "foo2" << "SHARED" << "${SRCS}";
 
124
    func2.addArguments( argList2 );
 
125
 
 
126
    argList3 << "foo3" << "EXCLUDE_FROM_ALL" << "${SRCS}";
 
127
    func3.addArguments( argList3 );
 
128
 
 
129
    argList4 << "foo4" << "MODULE" << "EXCLUDE_FROM_ALL" << "foo.c" << "bar.c" << "baz.c";
 
130
    func4.addArguments( argList4 );
 
131
    
 
132
    func5.addArguments( QString("krossui SHARED IMPORTED").split(' ') );
 
133
 
 
134
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
135
    QTest::newRow( "simple" ) << func;
 
136
    QTest::newRow( "shared" ) << func2;
 
137
    QTest::newRow( "exclude" ) << func3;
 
138
    QTest::newRow( "full" ) << func4;
 
139
    QTest::newRow( "imported" ) << func5;
 
140
}
 
141
 
 
142
void CMakeAstTest::testAddLibraryBadParse()
 
143
{
 
144
    QFETCH( CMakeFunctionDesc, function );
 
145
    CMakeAst* ast = AstFactory::self()->createAst("add_library");
 
146
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
147
    delete ast;
 
148
}
 
149
 
 
150
void CMakeAstTest::testAddLibraryBadParse_data()
 
151
{
 
152
    CMakeFunctionDesc func, func2, func3;
 
153
    QStringList argList, argList2, argList3;
 
154
 
 
155
    func.name = func2.name = func3.name = "add_library";
 
156
    func.name = "wrong_name";
 
157
    argList << "foo" << "${SRCS}";
 
158
    func.addArguments( argList );
 
159
 
 
160
    func2.addArguments( argList2 );
 
161
 
 
162
    argList3 << "no-sources" << "EXCLUDE_FROM_ALL";
 
163
    func3.addArguments( argList3 );
 
164
 
 
165
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
166
    QTest::newRow( "wrong name" ) << func;
 
167
    QTest::newRow( "no args" ) << func2;
 
168
    QTest::newRow( "no sources" ) << func3;
 
169
}
 
170
 
 
171
 
 
172
 
 
173
 
 
174
 
 
175
 
 
176
 
 
177
 
 
178
 
 
179
void CMakeAstTest::testAddSubdirectoryGoodParse()
 
180
{
 
181
    QFETCH( CMakeFunctionDesc, function );
 
182
    CMakeAst* ast = AstFactory::self()->createAst("add_subdirectory");
 
183
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
184
    delete ast;
 
185
}
 
186
 
 
187
void CMakeAstTest::testAddSubdirectoryGoodParse_data()
 
188
{
 
189
    CMakeFunctionDesc func, func2, func3, func4;
 
190
    func.name = "ADD_SUBDIRECTORY";
 
191
    func.addArguments( QStringList( "foodir" ) );
 
192
 
 
193
    func2.name = "add_subdirectory";
 
194
    func2.addArguments( QStringList( "foodir" ) );
 
195
 
 
196
    func3.name = "add_subdirectory";
 
197
    QStringList argList3;
 
198
    argList3 << "foodir" << "binary_foo_dir" << "EXCLUDE_FROM_ALL";
 
199
    func3.addArguments( argList3 );
 
200
 
 
201
    func4.name = "add_subdirectory";
 
202
    QStringList argList4;
 
203
    argList4 << "foodri" << "binary_foo_dir";
 
204
    func4.addArguments( argList4 );
 
205
 
 
206
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
207
    QTest::newRow( "good lowercase" ) << func;
 
208
    QTest::newRow( "good uppercase" ) << func2;
 
209
    QTest::newRow( "good all args" ) << func3;
 
210
    QTest::newRow( "good binary dir only" ) << func4;
 
211
}
 
212
 
 
213
void CMakeAstTest::testAddSubdirectoryBadParse()
 
214
{
 
215
    QFETCH( CMakeFunctionDesc, function );
 
216
    CMakeAst* ast = AstFactory::self()->createAst("add_subdirectory");
 
217
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
218
    delete ast;
 
219
}
 
220
 
 
221
void CMakeAstTest::testAddSubdirectoryBadParse_data()
 
222
{
 
223
    CMakeFunctionDesc func, func2;
 
224
    func.name = "ADD_SUBDIRECTORY";
 
225
    func2.name = "foobar";
 
226
 
 
227
    func2.addArguments( QStringList( "foodir" ) );
 
228
 
 
229
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
230
    QTest::newRow( "good lowercase" ) << func;
 
231
    QTest::newRow( "good uppercase" ) << func2;
 
232
}
 
233
 
 
234
void CMakeAstTest::testAddTestGoodParse()
 
235
{
 
236
    QFETCH( CMakeFunctionDesc, function );
 
237
    CMakeAst* ast = AstFactory::self()->createAst("add_test");
 
238
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
239
    delete ast;
 
240
}
 
241
 
 
242
void CMakeAstTest::testAddTestGoodParse_data()
 
243
{
 
244
    CMakeFunctionDesc func1, func2;
 
245
    func1.name = "ADD_TEST";
 
246
    func2.name = "add_test";
 
247
 
 
248
    QStringList argList1, argList2;
 
249
    argList1 << "test_name" << "exec_name";
 
250
    argList2 << "test_name" << "exec_name" << "arg1";
 
251
 
 
252
    func1.addArguments( argList1 );
 
253
    func2.addArguments( argList2 );
 
254
 
 
255
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
256
    QTest::newRow( "good req args" ) << func1;
 
257
    QTest::newRow( "good opt args" ) << func2;
 
258
}
 
259
 
 
260
void CMakeAstTest::testAddTestBadParse()
 
261
{
 
262
    QFETCH( CMakeFunctionDesc, function );
 
263
    CMakeAst* ast = AstFactory::self()->createAst("add_test");
 
264
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
265
    delete ast;
 
266
}
 
267
 
 
268
void CMakeAstTest::testAddTestBadParse_data()
 
269
{
 
270
    CMakeFunctionDesc func1, func2, func3;
 
271
    func1.name = "wrong_name";
 
272
    func2.name = func3.name = "add_test";
 
273
 
 
274
    QStringList argList1, argList2, argList3;
 
275
    argList1 << "some" << "args";
 
276
    argList2 << "one arg";
 
277
 
 
278
    func1.addArguments( argList1 );
 
279
    func2.addArguments( argList2 );
 
280
    func3.addArguments( argList3 );
 
281
 
 
282
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
283
    QTest::newRow( "wrong name" ) << func1;
 
284
    QTest::newRow( "not enough args" ) << func2;
 
285
    QTest::newRow( "no args" ) << func3;
 
286
 
 
287
}
 
288
 
 
289
 
 
290
 
 
291
 
 
292
 
 
293
 
 
294
 
 
295
 
 
296
 
 
297
 
 
298
void CMakeAstTest::testAuxSourceDirectoryGoodParse()
 
299
{
 
300
    QFETCH( CMakeFunctionDesc, function );
 
301
    CMakeAst* ast = AstFactory::self()->createAst("aux_source_directory");
 
302
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
303
    delete ast;
 
304
}
 
305
 
 
306
void CMakeAstTest::testAuxSourceDirectoryGoodParse_data()
 
307
{
 
308
    CMakeFunctionDesc func1, func2;
 
309
    func1.name = "AUX_SOURCE_DIRECTORY";
 
310
    func2.name = "aux_source_directory";
 
311
 
 
312
    QStringList argList;
 
313
    argList << "foo1" << "foo2";
 
314
 
 
315
    func1.addArguments( argList );
 
316
    func2.addArguments( argList );
 
317
 
 
318
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
319
    QTest::newRow( "good uppercase" ) << func1;
 
320
    QTest::newRow( "good lowercase" ) << func2;
 
321
}
 
322
 
 
323
void CMakeAstTest::testAuxSourceDirectoryBadParse()
 
324
{
 
325
    QFETCH( CMakeFunctionDesc, function );
 
326
    CMakeAst* ast = AstFactory::self()->createAst("aux_source_directory");
 
327
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
328
    delete ast;
 
329
}
 
330
 
 
331
void CMakeAstTest::testAuxSourceDirectoryBadParse_data()
 
332
{
 
333
    CMakeFunctionDesc func1, func2;
 
334
    func1.name = "AUX_SOURCE_DIRECTORY";
 
335
    func2.name = "wrong name";
 
336
 
 
337
    QStringList argList;
 
338
    argList << "foo1" << "foo2";
 
339
 
 
340
    func2.addArguments( argList );
 
341
 
 
342
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
343
    QTest::newRow( "bad no args" ) << func1;
 
344
    QTest::newRow( "bad wrong name" ) << func2;
 
345
}
 
346
 
 
347
void CMakeAstTest::testBreakGoodParse()
 
348
{
 
349
    QFETCH( CMakeFunctionDesc, function );
 
350
    CMakeAst* ast = AstFactory::self()->createAst("break");
 
351
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
352
    delete ast;
 
353
}
 
354
 
 
355
void CMakeAstTest::testBreakGoodParse_data()
 
356
{
 
357
    CMakeFunctionDesc func1, func2;
 
358
    func1.name = "break";
 
359
 
 
360
    func2.addArguments( QStringList() );
 
361
 
 
362
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
363
    QTest::newRow( "good" ) << func1;
 
364
}
 
365
 
 
366
void CMakeAstTest::testBreakBadParse()
 
367
{
 
368
    QFETCH( CMakeFunctionDesc, function );
 
369
    CMakeAst* ast = AstFactory::self()->createAst("break");
 
370
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
371
    delete ast;
 
372
}
 
373
 
 
374
void CMakeAstTest::testBreakBadParse_data()
 
375
{
 
376
    CMakeFunctionDesc func1, func2;
 
377
    func1.name = "break";
 
378
    func2.name = "wrong name";
 
379
 
 
380
    QStringList argList;
 
381
    argList << "foo1" << "foo2";
 
382
 
 
383
    func1.addArguments( argList );
 
384
 
 
385
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
386
    QTest::newRow( "bad with args" ) << func1;
 
387
    QTest::newRow( "bad wrong name" ) << func2;
 
388
}
 
389
 
 
390
void CMakeAstTest::testBuildCommandGoodParse()
 
391
{
 
392
    QFETCH( CMakeFunctionDesc, function );
 
393
    CMakeAst* ast = AstFactory::self()->createAst("build_command");
 
394
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
395
    delete ast;
 
396
}
 
397
 
 
398
void CMakeAstTest::testBuildCommandGoodParse_data()
 
399
{
 
400
    CMakeFunctionDesc func1, func2;
 
401
    func1.name = "build_command";
 
402
    func2.name = func1.name.toUpper();
 
403
 
 
404
    QStringList argList;
 
405
    argList << "mybuildtool" << "my_cool_build";
 
406
    func1.addArguments( argList );
 
407
    func2.arguments = func1.arguments;
 
408
 
 
409
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
410
    QTest::newRow( "good lower" ) << func1;
 
411
    QTest::newRow( "good upper" ) << func2;
 
412
}
 
413
 
 
414
void CMakeAstTest::testBuildCommandBadParse()
 
415
{
 
416
    QFETCH( CMakeFunctionDesc, function );
 
417
    CMakeAst* ast = AstFactory::self()->createAst("build_command");
 
418
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
419
    delete ast;
 
420
}
 
421
 
 
422
void CMakeAstTest::testBuildCommandBadParse_data()
 
423
{
 
424
    CMakeFunctionDesc func1, func2, func3;
 
425
    func1.name = "build_command";
 
426
    func2.name = "some_other_foo";
 
427
    func3.name = func1.name;
 
428
 
 
429
    QStringList argList, argList2;
 
430
    argList << "mymake" << "unsermake";
 
431
    argList2 << "single argument";
 
432
    func2.addArguments( argList );
 
433
    func3.addArguments( argList2 );
 
434
 
 
435
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
436
    QTest::newRow( "bad no args" ) << func1;
 
437
    QTest::newRow( "bad wrong name" ) << func2;
 
438
    QTest::newRow( "bad not enough args" ) << func3;
 
439
}
 
440
 
 
441
 
 
442
 
 
443
 
 
444
 
 
445
 
 
446
 
 
447
 
 
448
 
 
449
 
 
450
void CMakeAstTest::testBuildNameGoodParse()
 
451
{
 
452
    QFETCH( CMakeFunctionDesc, function );
 
453
    CMakeAst* ast = AstFactory::self()->createAst("build_name");
 
454
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
455
    delete ast;
 
456
}
 
457
 
 
458
void CMakeAstTest::testBuildNameGoodParse_data()
 
459
{
 
460
    CMakeFunctionDesc func1, func2;
 
461
    func1.name = "build_name";
 
462
    func2.name = func1.name.toUpper();
 
463
 
 
464
    QStringList argList;
 
465
    argList << "my_cool_build";
 
466
    func1.addArguments( argList );
 
467
    func2.arguments = func1.arguments;
 
468
 
 
469
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
470
    QTest::newRow( "good lower" ) << func1;
 
471
    QTest::newRow( "good upper" ) << func2;
 
472
}
 
473
 
 
474
void CMakeAstTest::testBuildNameBadParse()
 
475
{
 
476
    QFETCH( CMakeFunctionDesc, function );
 
477
    CMakeAst* ast = AstFactory::self()->createAst("build_name");
 
478
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
479
    delete ast;
 
480
}
 
481
 
 
482
void CMakeAstTest::testBuildNameBadParse_data()
 
483
{
 
484
    CMakeFunctionDesc func1, func2;
 
485
    func1.name = "build_name";
 
486
    func2.name = "wrong_func_name";
 
487
 
 
488
    QStringList argList;
 
489
    argList << "my_cool_build";
 
490
    func2.arguments = func1.arguments;
 
491
 
 
492
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
493
    QTest::newRow( "bad no args" ) << func1;
 
494
    QTest::newRow( "ban wrong name" ) << func2;
 
495
}
 
496
 
 
497
void CMakeAstTest::testCMakeMinimumRequiredGoodParse()
 
498
{
 
499
    QFETCH( CMakeFunctionDesc, function );
 
500
    CMakeAst* ast = AstFactory::self()->createAst("cmake_minimum_required");
 
501
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
502
    delete ast;
 
503
}
 
504
 
 
505
void CMakeAstTest::testCMakeMinimumRequiredGoodParse_data()
 
506
{
 
507
    CMakeFunctionDesc func1, func2, func3;
 
508
    func1.name = "CMAKE_MINIMUM_REQUIRED";
 
509
    func2.name = func3.name = func1.name.toLower();
 
510
    QStringList argList1, argList2, argList3;
 
511
 
 
512
    argList1 << "VERSION" << "2.4";
 
513
    argList2 = argList1;
 
514
    argList2 << "FATAL_ERROR";
 
515
 
 
516
    func1.addArguments( argList1 );
 
517
    func2.addArguments( argList1 );
 
518
    func3.addArguments( argList2 );
 
519
 
 
520
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
521
    QTest::newRow( "good upper case" ) << func1;
 
522
    QTest::newRow( "good lower case" ) << func2;
 
523
    QTest::newRow( "good all args" ) << func3;
 
524
}
 
525
 
 
526
void CMakeAstTest::testCMakeMinimumRequiredBadParse()
 
527
{
 
528
    QFETCH( CMakeFunctionDesc, function );
 
529
    CMakeAst* ast = AstFactory::self()->createAst("cmake_minimum_required");
 
530
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
531
    delete ast;
 
532
}
 
533
 
 
534
void CMakeAstTest::testCMakeMinimumRequiredBadParse_data()
 
535
{
 
536
    CMakeFunctionDesc func1, func2, func3, func4;
 
537
    func1.name = "wrong_name";
 
538
    func2.name = func3.name = "cmake_required_version";
 
539
    func4.name = func3.name;
 
540
    QStringList argList1, argList2, argList3, argList4;
 
541
 
 
542
    argList1 << "VERSION" << "2.4";
 
543
    argList2 << "VERSION";
 
544
    argList3 << "VERSION" << "FATAL_ERROR";
 
545
 
 
546
 
 
547
    func1.addArguments( argList1 );
 
548
    func2.addArguments( argList1 );
 
549
    func3.addArguments( argList3 );
 
550
 
 
551
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
552
    QTest::newRow( "wrong name" ) << func1;
 
553
    QTest::newRow( "no version number 1" ) << func2;
 
554
    QTest::newRow( "no version number 2" ) << func3;
 
555
    QTest::newRow( "no arguments" ) << func4;
 
556
}
 
557
 
 
558
void CMakeAstTest::testCMakePolicyGoodParse()
 
559
{
 
560
    QFETCH( CMakeFunctionDesc, function );
 
561
    CMakeAst* ast = AstFactory::self()->createAst("cmake_policy");
 
562
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
563
    delete ast;
 
564
}
 
565
 
 
566
void CMakeAstTest::testCMakePolicyGoodParse_data()
 
567
{
 
568
    CMakeFunctionDesc func[4];
 
569
    func[0].name = "CMAKE_POLICY";
 
570
    func[1].name = func[2].name = func[3].name = func[0].name.toLower();
 
571
    QStringList argList[4];
 
572
 
 
573
    argList[0] << "VERSION" << "2.4";
 
574
    argList[1] << "SET" << "CMP333" << "NEW";
 
575
    argList[2] << "POP";
 
576
    argList[3] << "PUSH";
 
577
 
 
578
    func[0].addArguments( argList[0] );
 
579
    func[1].addArguments( argList[1] );
 
580
    func[2].addArguments( argList[2] );
 
581
    func[3].addArguments( argList[3] );
 
582
 
 
583
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
584
    QTest::newRow( "good version" ) << func[0];
 
585
    QTest::newRow( "good cmpset" ) << func[1];
 
586
    QTest::newRow( "good pop" ) << func[2];
 
587
    QTest::newRow( "good push" ) << func[3];
 
588
}
 
589
 
 
590
void CMakeAstTest::testCMakePolicyBadParse()
 
591
{
 
592
    QFETCH( CMakeFunctionDesc, function );
 
593
    CMakeAst* ast = AstFactory::self()->createAst("cmake_policy");
 
594
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
595
    delete ast;
 
596
}
 
597
 
 
598
void CMakeAstTest::testCMakePolicyBadParse_data()
 
599
{
 
600
    CMakeFunctionDesc func[6];
 
601
    func[0].name = "iamwrong";
 
602
    func[1].name = func[2].name = func[3].name = func[4].name = func[5].name = "cmake_policy";
 
603
    QStringList argList[5];
 
604
 
 
605
    argList[0] << "VERSION" << "AB";
 
606
    argList[1] << "SET" << "CMP123" << "NOTNEW";
 
607
    argList[2] << "POP" << "33";
 
608
    argList[3] << "PUSH" << "44";
 
609
    argList[4] << "BUTTERFLY" << "44";
 
610
 
 
611
    func[0].addArguments( argList[0] );
 
612
    func[1].addArguments( argList[0] );
 
613
    func[2].addArguments( argList[1] );
 
614
    func[3].addArguments( argList[2] );
 
615
    func[4].addArguments( argList[3] );
 
616
    func[5].addArguments( argList[4] );
 
617
 
 
618
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
619
    QTest::newRow( "bad name" ) << func[0];
 
620
    QTest::newRow( "bad version" ) << func[1];
 
621
    QTest::newRow( "bad cmpset" ) << func[2];
 
622
    QTest::newRow( "bad pop" ) << func[3];
 
623
    QTest::newRow( "bad push" ) << func[4];
 
624
    QTest::newRow( "bad parameter" ) << func[4];
 
625
 
 
626
}
 
627
 
 
628
void CMakeAstTest::testConfigureFileGoodParse()
 
629
{
 
630
    QFETCH( CMakeFunctionDesc, function );
 
631
    CMakeAst* ast = AstFactory::self()->createAst("configure_file");
 
632
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
633
    delete ast;
 
634
}
 
635
 
 
636
void CMakeAstTest::testConfigureFileGoodParse_data()
 
637
{
 
638
    CMakeFunctionDesc func1, func2, func3, func4, func5;
 
639
    func1.name = "CONFIGURE_FILE";
 
640
    func2.name = func1.name.toLower();
 
641
    func3.name = func4.name = func5.name = func2.name;
 
642
 
 
643
    QStringList argList1, argList2, argList3, argList4;
 
644
    argList1 << "inputfile" << "outputfile";
 
645
    argList2 = argList1 << "COPYONLY";
 
646
    argList3 = argList2 << "ESCAPE_QUOTES";
 
647
    argList4 = argList3 << "@ONLY";
 
648
 
 
649
    func1.addArguments( argList1 );
 
650
    func2.addArguments( argList1 );
 
651
    func3.addArguments( argList2 );
 
652
    func4.addArguments( argList3 );
 
653
    func5.addArguments( argList4 );
 
654
 
 
655
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
656
    QTest::newRow( "good uppercase min args" ) << func1;
 
657
    QTest::newRow( "good lowercase min args" ) << func2;
 
658
    QTest::newRow( "good lowercase 3 args" ) << func3;
 
659
    QTest::newRow( "good lowercase 4 args" ) << func4;
 
660
    QTest::newRow( "good lowercase 5 args" ) << func5;
 
661
}
 
662
 
 
663
void CMakeAstTest::testConfigureFileBadParse()
 
664
{
 
665
    QFETCH( CMakeFunctionDesc, function );
 
666
    CMakeAst* ast = AstFactory::self()->createAst("configure_file");
 
667
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
668
    delete ast;
 
669
}
 
670
 
 
671
void CMakeAstTest::testConfigureFileBadParse_data()
 
672
{
 
673
    CMakeFunctionDesc func1, func2, func3;
 
674
    func1.name = "wrong_func_name";
 
675
    func2.name = func3.name = "configure_file";
 
676
 
 
677
    QStringList argList1, argList2, argList3;
 
678
    argList1 << "sourcefile" << "outputfile";
 
679
    argList2 << "only_one";
 
680
 
 
681
    func1.addArguments( argList1 );
 
682
    func2.addArguments( argList2 );
 
683
    func3.addArguments( argList3 );
 
684
 
 
685
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
686
    QTest::newRow( "bad wrong name" ) << func1;
 
687
    QTest::newRow( "bad only one arg" ) << func2;
 
688
    QTest::newRow( "bad no args" ) << func3;
 
689
}
 
690
 
 
691
void CMakeAstTest::testCreateTestSourcelistGoodParse()
 
692
{
 
693
    QFETCH( CMakeFunctionDesc, function );
 
694
    CMakeAst* ast = AstFactory::self()->createAst("create_test_sourcelist");
 
695
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
696
    delete ast;
 
697
}
 
698
 
 
699
void CMakeAstTest::testCreateTestSourcelistGoodParse_data()
 
700
{
 
701
    CMakeFunctionDesc func1, func2, func3, func4;
 
702
    func1.name = "create_test_sourcelist";
 
703
    func2.name = func1.name;
 
704
    func3.name = func2.name.toUpper();
 
705
    func4.name = func3.name;
 
706
 
 
707
    QStringList argList1, argList2, argList3, argList4;
 
708
    argList1 << "$(TESTDRIVER_SRCS)" << "test_driver" << "$(TEST_SRCS)";
 
709
    argList2 = argList1;
 
710
    argList2 << "EXTRA_INCLUDE" << "include.h";
 
711
    argList3 = argList1;
 
712
    argList3 << "FUNCTION" << "function";
 
713
    argList4 = argList1;
 
714
    argList4 << "EXTRA_INCLUDE" << "include.h";
 
715
    argList4 << "FUNCTION" << "function";
 
716
 
 
717
    func1.addArguments( argList1 );
 
718
    func2.addArguments( argList2 );
 
719
    func3.addArguments( argList3 );
 
720
    func4.addArguments( argList4 );
 
721
 
 
722
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
723
    QTest::newRow( "good min lower case" ) << func1;
 
724
    QTest::newRow( "good lower case extra include" ) << func2;
 
725
    QTest::newRow( "good upper extra function" ) << func3;
 
726
    QTest::newRow( "good upper all args" ) << func4;
 
727
}
 
728
 
 
729
void CMakeAstTest::testCreateTestSourcelistBadParse()
 
730
{
 
731
    QFETCH( CMakeFunctionDesc, function );
 
732
    CMakeAst* ast = AstFactory::self()->createAst("create_test_sourcelist");
 
733
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
734
    delete ast;
 
735
}
 
736
 
 
737
void CMakeAstTest::testCreateTestSourcelistBadParse_data()
 
738
{
 
739
    CMakeFunctionDesc func1, func2, func3, func4;
 
740
    func1.name = "create_test_sourcelists";
 
741
    func2.name = "create_test_sourcelist";
 
742
    func3.name = func2.name.toUpper();
 
743
    func4.name = func3.name;
 
744
 
 
745
    QStringList argList1, argList2, argList3, argList4;
 
746
    argList1 << "$(TESTDRIVER_SRCS) test_driver $(TEST_SRCS)";
 
747
    argList2 = argList1;
 
748
    argList2 << "EXTRA_INCLUDE";
 
749
    argList3 = argList1;
 
750
    argList3 << "FUNCTION";
 
751
    argList4 << "foo bar";
 
752
 
 
753
    func1.addArguments( argList1 );
 
754
    func2.addArguments( argList2 );
 
755
    func3.addArguments( argList3 );
 
756
    func4.addArguments( argList4 );
 
757
 
 
758
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
759
    QTest::newRow( "bad name lower case" ) << func1;
 
760
    QTest::newRow( "bad extra include not enough args" ) << func2;
 
761
    QTest::newRow( "bad extra function not enough args" ) << func3;
 
762
    QTest::newRow( "bad upper need at least 3 args" ) << func4;
 
763
}
 
764
 
 
765
 
 
766
 
 
767
 
 
768
 
 
769
 
 
770
 
 
771
 
 
772
 
 
773
 
 
774
void CMakeAstTest::testEnableLanguageGoodParse()
 
775
{
 
776
    QFETCH( CMakeFunctionDesc, function );
 
777
    CMakeAst* ast = AstFactory::self()->createAst("enable_language");
 
778
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
779
    delete ast;
 
780
}
 
781
 
 
782
void CMakeAstTest::testEnableLanguageGoodParse_data()
 
783
{
 
784
    CMakeFunctionDesc func1, func2;
 
785
    func1.name = "ENABLE_LANGUAGE";
 
786
    func2.name = "enable_language";
 
787
 
 
788
    QStringList argList1, argList2;
 
789
    argList1 << "C++";
 
790
    argList2 << "Java";
 
791
 
 
792
    func1.addArguments( argList1 );
 
793
    func2.addArguments( argList2 );
 
794
 
 
795
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
796
    QTest::newRow( "good uppercase" ) << func1;
 
797
    QTest::newRow( "good lowercase" ) << func2;
 
798
}
 
799
 
 
800
void CMakeAstTest::testEnableLanguageBadParse()
 
801
{
 
802
    QFETCH( CMakeFunctionDesc, function );
 
803
    CMakeAst* ast = AstFactory::self()->createAst("enable_language");
 
804
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
805
    delete ast;
 
806
}
 
807
 
 
808
void CMakeAstTest::testEnableLanguageBadParse_data()
 
809
{
 
810
    CMakeFunctionDesc func1, func2;
 
811
    func1.name = "ENABLE_LANGUAGES";
 
812
    func2.name = "enable_language";
 
813
 
 
814
    QStringList argList1, argList2;
 
815
    argList1 << "C++";
 
816
 
 
817
    func1.addArguments( argList1 );
 
818
    func2.addArguments( argList2 );
 
819
 
 
820
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
821
    QTest::newRow( "bad uppercase" ) << func1;
 
822
    QTest::newRow( "bad lowercase. no param" ) << func2;
 
823
}
 
824
 
 
825
 
 
826
 
 
827
 
 
828
 
 
829
 
 
830
 
 
831
 
 
832
 
 
833
 
 
834
void CMakeAstTest::testEnableTestingGoodParse()
 
835
{
 
836
    QFETCH( CMakeFunctionDesc, function );
 
837
    CMakeAst* ast = AstFactory::self()->createAst("enable_testing");
 
838
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
839
    delete ast;
 
840
}
 
841
 
 
842
void CMakeAstTest::testEnableTestingGoodParse_data()
 
843
{
 
844
    CMakeFunctionDesc func1, func2;
 
845
    func1.name = "ENABLE_TESTING";
 
846
    func2.name = "enable_testing";
 
847
 
 
848
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
849
    QTest::newRow( "good upper" ) << func1;
 
850
    QTest::newRow( "good lower" ) << func2;
 
851
 
 
852
}
 
853
 
 
854
void CMakeAstTest::testEnableTestingBadParse()
 
855
{
 
856
    QFETCH( CMakeFunctionDesc, function );
 
857
    CMakeAst* ast = AstFactory::self()->createAst("enable_testing");
 
858
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
859
    delete ast;
 
860
}
 
861
 
 
862
void CMakeAstTest::testEnableTestingBadParse_data()
 
863
{
 
864
    CMakeFunctionDesc func1, func2;
 
865
    func1.name = "bad_func_name";
 
866
    func2.name = "enable_testing";
 
867
 
 
868
    QStringList argList;
 
869
    argList << "foo";
 
870
 
 
871
    func2.addArguments( argList );
 
872
 
 
873
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
874
    QTest::newRow( "bad wrong name" ) << func1;
 
875
    QTest::newRow( "bad has args" ) << func2;
 
876
 
 
877
}
 
878
 
 
879
 
 
880
 
 
881
 
 
882
 
 
883
 
 
884
 
 
885
 
 
886
 
 
887
 
 
888
void CMakeAstTest::testExecProgramGoodParse()
 
889
{
 
890
    QFETCH( CMakeFunctionDesc, function );
 
891
    CMakeAst* ast = AstFactory::self()->createAst("exec_program");
 
892
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
893
    delete ast;
 
894
}
 
895
 
 
896
void CMakeAstTest::testExecProgramGoodParse_data()
 
897
{
 
898
    CMakeFunctionDesc func1, func2, func3, func4;
 
899
    func1.name = "exec_program";
 
900
    func2.name = func1.name.toUpper();
 
901
    func3.name = func4.name = func1.name;
 
902
 
 
903
    QStringList argList1, argList2, argList3, argList4;
 
904
    argList1 << "myExec";
 
905
    argList2 = argList1;
 
906
    argList2 << "myRunDir";
 
907
    argList3 = argList1;
 
908
    argList3 << "ARGS" << "arg1" << "arg2";
 
909
    argList4 = argList1;
 
910
    argList4 << "RETURN_VALUE" << "myReturnVar";
 
911
 
 
912
    func1.addArguments( argList1 );
 
913
    func2.addArguments( argList2 );
 
914
    func3.addArguments( argList3 );
 
915
    func4.addArguments( argList4 );
 
916
 
 
917
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
918
    QTest::newRow( "good 1" ) << func1;
 
919
    QTest::newRow( "good 2" ) << func2;
 
920
    QTest::newRow( "good 3" ) << func3;
 
921
    QTest::newRow( "good 4" ) << func4;
 
922
 
 
923
}
 
924
 
 
925
void CMakeAstTest::testExecProgramBadParse()
 
926
{
 
927
    QFETCH( CMakeFunctionDesc, function );
 
928
    CMakeAst* ast = AstFactory::self()->createAst("exec_program");
 
929
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
930
    delete ast;
 
931
}
 
932
 
 
933
void CMakeAstTest::testExecProgramBadParse_data()
 
934
{
 
935
    CMakeFunctionDesc func1, func2;
 
936
    func1.name = "wrong_name_here";
 
937
    func2.name = "exec_program";
 
938
 
 
939
    QStringList argList1;
 
940
    argList1 << "myExec";
 
941
 
 
942
    func1.addArguments( argList1 );
 
943
 
 
944
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
945
    QTest::newRow( "bad 1" ) << func1;
 
946
    QTest::newRow( "bad 2" ) << func2;
 
947
}
 
948
 
 
949
 
 
950
 
 
951
 
 
952
 
 
953
 
 
954
 
 
955
 
 
956
#define TDD_TODO QSKIP("No data available yet", SkipSingle)
 
957
#define TDD_TOIMPL QSKIP("Command not implemented yet", SkipSingle)
 
958
 
 
959
void CMakeAstTest::testExecuteProcessGoodParse()
 
960
{
 
961
    TDD_TODO;
 
962
    QFETCH( CMakeFunctionDesc, function );
 
963
    CMakeAst* ast = AstFactory::self()->createAst("execute_process");
 
964
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
965
    delete ast;
 
966
}
 
967
 
 
968
void CMakeAstTest::testExecuteProcessGoodParse_data()
 
969
{
 
970
}
 
971
 
 
972
void CMakeAstTest::testExecuteProcessBadParse()
 
973
{
 
974
    TDD_TODO;
 
975
    QFETCH( CMakeFunctionDesc, function );
 
976
    CMakeAst* ast = AstFactory::self()->createAst("execute_process");
 
977
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
978
    delete ast;
 
979
}
 
980
 
 
981
void CMakeAstTest::testExecuteProcessBadParse_data()
 
982
{
 
983
}
 
984
 
 
985
void CMakeAstTest::testExportGoodParse()
 
986
{
 
987
    TDD_TODO;
 
988
    QFETCH( CMakeFunctionDesc, function );
 
989
    CMakeAst* ast = AstFactory::self()->createAst("export");
 
990
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
991
    delete ast;
 
992
}
 
993
 
 
994
void CMakeAstTest::testExportGoodParse_data()
 
995
{
 
996
}
 
997
 
 
998
void CMakeAstTest::testExportBadParse()
 
999
{
 
1000
    TDD_TODO;
 
1001
    QFETCH( CMakeFunctionDesc, function );
 
1002
    CMakeAst* ast = AstFactory::self()->createAst("export");
 
1003
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1004
    delete ast;
 
1005
}
 
1006
 
 
1007
void CMakeAstTest::testExportBadParse_data()
 
1008
{
 
1009
}
 
1010
 
 
1011
 
 
1012
 
 
1013
 
 
1014
 
 
1015
 
 
1016
 
 
1017
 
 
1018
 
 
1019
 
 
1020
void CMakeAstTest::testExportLibraryDepsGoodParse()
 
1021
{
 
1022
    QFETCH( CMakeFunctionDesc, function );
 
1023
    CMakeAst* ast = AstFactory::self()->createAst("export_library_dependencies");
 
1024
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1025
    delete ast;
 
1026
}
 
1027
 
 
1028
void CMakeAstTest::testExportLibraryDepsGoodParse_data()
 
1029
{
 
1030
    CMakeFunctionDesc func1, func2;
 
1031
    func1.name = func2.name = "export_library_dependencies";
 
1032
 
 
1033
    QStringList argList1, argList2;
 
1034
    argList1 << "dep_file";
 
1035
    argList2 = argList1;
 
1036
    argList2 << "APPEND";
 
1037
 
 
1038
    func1.addArguments( argList1 );
 
1039
    func2.addArguments( argList2 );
 
1040
 
 
1041
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1042
    QTest::newRow( "good 1" ) << func1;
 
1043
    QTest::newRow( "good 2" ) << func2;
 
1044
}
 
1045
 
 
1046
void CMakeAstTest::testExportLibraryDepsBadParse()
 
1047
{
 
1048
    QFETCH( CMakeFunctionDesc, function );
 
1049
    CMakeAst* ast = AstFactory::self()->createAst("export_library_dependencies");
 
1050
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1051
    delete ast;
 
1052
}
 
1053
 
 
1054
void CMakeAstTest::testExportLibraryDepsBadParse_data()
 
1055
{
 
1056
    CMakeFunctionDesc func1, func2;
 
1057
    func1.name = "export_library_dependencies";
 
1058
    func2.name = "foo_foo_bar";
 
1059
 
 
1060
    QStringList argList1, argList2;
 
1061
    argList1 << "dep_file" << "lalala";
 
1062
    argList2 << "dep_file";
 
1063
 
 
1064
    func1.addArguments( argList1 );
 
1065
    func2.addArguments( argList2 );
 
1066
 
 
1067
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1068
    QTest::newRow( "bad 1" ) << func1;
 
1069
    QTest::newRow( "bad 2" ) << func2;
 
1070
}
 
1071
 
 
1072
 
 
1073
 
 
1074
 
 
1075
 
 
1076
 
 
1077
 
 
1078
 
 
1079
 
 
1080
 
 
1081
void CMakeAstTest::testFileGoodParse()
 
1082
{
 
1083
    QFETCH( CMakeFunctionDesc, function );
 
1084
    CMakeAst* ast = AstFactory::self()->createAst("file");
 
1085
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1086
    delete ast;
 
1087
}
 
1088
 
 
1089
void CMakeAstTest::testFileGoodParse_data()
 
1090
{
 
1091
    const int NUM_TESTDATA = 13;
 
1092
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
1093
    QStringList args[NUM_TESTDATA];
 
1094
 
 
1095
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
1096
        funcs[i].name = "FILE";
 
1097
 
 
1098
    //write file command
 
1099
    args[0] << "WRITE" << "somefile.cpp" << "\"the things to write\"";
 
1100
 
 
1101
    //append file command
 
1102
    args[1] << "APPEND" << "somefile.cpp" << "\"the things to append\"";
 
1103
 
 
1104
    //read file command
 
1105
    args[2] << "READ" << "somefile.cpp" << "MY_VAR";
 
1106
 
 
1107
    //glob files command. does not search in files only for a pattern
 
1108
    args[3] << "GLOB" << "MY_VAR" << "*.cpp";
 
1109
    args[4] << "GLOB" << "MY_VAR" << "RELATIVE" << "/path/to/something"
 
1110
            << "*.cpp"; //RELATIVE is optional
 
1111
 
 
1112
    //recursive glob
 
1113
    args[5] << "GLOB_RECURSE" << "MY_VAR" << "*.cpp";
 
1114
    args[6] << "GLOB_RECURSE" << "MY_VAR" << "RELATIVE" << "/path/to/something"
 
1115
            << "*.cpp"; //RELATIVE is optional
 
1116
 
 
1117
    //remove command
 
1118
    args[7] << "REMOVE" << "/path/to/file/to/remove.cpp";
 
1119
 
 
1120
    //remove recursive
 
1121
    args[8] << "REMOVE_RECURSE" << "/path/to/dir/to/remove/files";
 
1122
 
 
1123
    //make a directory
 
1124
    args[9] << "MAKE_DIRECTORY" << "/path/to/dir/to/create";
 
1125
 
 
1126
    //get a relative path
 
1127
    args[10] << "RELATIVE_PATH" << "MY_VAR" << "/path/to/foo"
 
1128
             << "/path/to/file/to/get/path/for.cpp";
 
1129
 
 
1130
    //get the cmake native path
 
1131
    args[11] << "TO_CMAKE_PATH" << "/path/to/file.cpp" << "MY_CMAKE_PATH";
 
1132
 
 
1133
    //get the platform native path
 
1134
    args[12] << "TO_NATIVE_PATH" << "/path/to/file.cpp" << "MY_NATIVE_PATH";
 
1135
 
 
1136
 
 
1137
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1138
 
 
1139
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
1140
    {
 
1141
        funcs[i].addArguments( args[i] );
 
1142
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
1143
    }
 
1144
 
 
1145
}
 
1146
 
 
1147
void CMakeAstTest::testFileBadParse()
 
1148
{
 
1149
    QFETCH( CMakeFunctionDesc, function );
 
1150
    CMakeAst* ast = AstFactory::self()->createAst("file");
 
1151
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1152
    delete ast;
 
1153
}
 
1154
 
 
1155
void CMakeAstTest::testFileBadParse_data()
 
1156
{
 
1157
 
 
1158
    const int NUM_TESTDATA = 35;
 
1159
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
1160
    QStringList args[NUM_TESTDATA];
 
1161
 
 
1162
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
1163
        funcs[i].name = "FILE";
 
1164
 
 
1165
    funcs[NUM_TESTDATA - 1].name = "foo";
 
1166
    
 
1167
    //write file command
 
1168
    args[0] << "WRITE" << "somefile.cpp"; //nothing to write
 
1169
    args[1] << "WRITE"; //no file
 
1170
    args[2] << "write" << "somefile.cpp" << "thing to write"; //uppercase required
 
1171
 
 
1172
    //append file command
 
1173
    args[3] << "APPEND" << "somefile.cpp"; //nothing to append
 
1174
    args[4] << "APPEND"; //no file
 
1175
    args[5] << "append" << "somefile.cpp" << "thing to append"; //uppercase required
 
1176
 
 
1177
    //read file command
 
1178
    args[6] << "READ" << "somefile.cpp"; //no variable
 
1179
    args[7] << "READ"; //no file
 
1180
    args[8] << "read" << "somefile.cpp" << "MY_VAR"; //uppercase required
 
1181
 
 
1182
    //glob files command. does not search in files only for a pattern
 
1183
    args[9] << "GLOB"; //no variable
 
1184
    args[10] << "GLOB" << "MY_VAR" << "RELATIVE"; //no path
 
1185
    
 
1186
    args[11] << "glob" << "MY_VAR" << "*.cpp"; //uppercase required
 
1187
 
 
1188
    //recursive glob
 
1189
    args[13] << "GLOB_RECURSE"; //no variable
 
1190
    args[14] << "GLOB_RECURSE" << "MY_VAR" << "RELATIVE"; //no path
 
1191
 
 
1192
    args[15] << "glob_recurse" << "MY_VAR" << "*.cpp"; //uppercase required
 
1193
 
 
1194
    //remove command
 
1195
    args[17] << "REMOVE"; //nothing to remove
 
1196
    args[18] << "remove" << "/path/to/file/to/remove.cpp";
 
1197
 
 
1198
    //remove recursive
 
1199
    args[19] << "REMOVE_RECURSE"; //nothing to remove
 
1200
    args[20] << "remove_recurse" << "/path/to/dir"; //uppercase required
 
1201
 
 
1202
    //make a directory
 
1203
    args[21] << "MAKE_DIRECTORY"; //nothing to create
 
1204
    args[22] << "make_directory" << "/path/to/dir"; //uppercase required
 
1205
 
 
1206
    //get a relative path
 
1207
    args[23] << "RELATIVE_PATH" << "MY_VAR" << "/path/to/foo"; //no file
 
1208
    args[24] << "RELATIVE_PATH" << "MY_VAR"; //no path and no file
 
1209
    args[25] << "RELATIVE_PATH"; //no variable, path, or file
 
1210
    args[26] << "relative_path" << "MY_VAR" << "/path/to/foo"
 
1211
        << "/path/to/file/to/get/full/path/for.cpp"; // uppercase required
 
1212
 
 
1213
    //get the cmake native path
 
1214
    args[27] << "TO_CMAKE_PATH" << "/path/to/file.cpp"; // no variable
 
1215
    args[28] << "TO_CMAKE_PATH"; //no path or variable
 
1216
    args[29] << "to_cmake_path" << "/path/to/file.cpp" << "MY_VAR"; //uppercase required
 
1217
    
 
1218
    //get the platform native path
 
1219
    args[30] << "TO_NATIVE_PATH" << "/path/to/file.cpp"; //no variable
 
1220
    args[31] << "TO_NATIVE_PATH"; //no path or variable
 
1221
    args[32] << "to_native_path" << "/path/to/file.cpp" << "MY_VAR"; //uppercase required
 
1222
    
 
1223
    args[34] << "TO_NATIVE_PATH" << "/path/to/file.cpp" << "MY_VAR"; //correct args. wrong name
 
1224
    
 
1225
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1226
 
 
1227
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
1228
    {
 
1229
        funcs[i].addArguments( args[i] );
 
1230
        QTest::newRow( qPrintable(QString("%1. %2").arg(i).arg(args[i].isEmpty() ? "?" : args[i].first())) ) << funcs[i];
 
1231
    }
 
1232
 
 
1233
}
 
1234
 
 
1235
 
 
1236
 
 
1237
 
 
1238
 
 
1239
 
 
1240
 
 
1241
 
 
1242
 
 
1243
 
 
1244
void CMakeAstTest::testFindFileGoodParse()
 
1245
{
 
1246
    TDD_TODO;
 
1247
    QFETCH( CMakeFunctionDesc, function );
 
1248
    CMakeAst* ast = AstFactory::self()->createAst("find_file");
 
1249
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1250
    delete ast;
 
1251
}
 
1252
 
 
1253
void CMakeAstTest::testFindFileGoodParse_data()
 
1254
{
 
1255
}
 
1256
 
 
1257
void CMakeAstTest::testFindFileBadParse()
 
1258
{
 
1259
    TDD_TODO;
 
1260
    QFETCH( CMakeFunctionDesc, function );
 
1261
    CMakeAst* ast = AstFactory::self()->createAst("find_file");
 
1262
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1263
    delete ast;
 
1264
}
 
1265
 
 
1266
void CMakeAstTest::testFindFileBadParse_data()
 
1267
{
 
1268
}
 
1269
 
 
1270
 
 
1271
 
 
1272
 
 
1273
 
 
1274
 
 
1275
 
 
1276
 
 
1277
 
 
1278
 
 
1279
void CMakeAstTest::testFindLibraryGoodParse()
 
1280
{
 
1281
    QFETCH( CMakeFunctionDesc, function );
 
1282
    CMakeAst* ast = AstFactory::self()->createAst("find_library");
 
1283
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1284
    delete ast;
 
1285
}
 
1286
 
 
1287
void CMakeAstTest::testFindLibraryGoodParse_data()
 
1288
{
 
1289
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1290
    
 
1291
    CMakeFunctionDesc l;
 
1292
    l.name = "find_library";
 
1293
    l.addArguments(QString("DEST_VAR name").split(' '));
 
1294
    QTest::newRow("findlib with name") << l;
 
1295
    
 
1296
    l.arguments.clear();
 
1297
    l.addArguments(QString("DEST_VAR name /path/to/lib").split(' '));
 
1298
    QTest::newRow("findlib with name and path") << l;
 
1299
}
 
1300
 
 
1301
void CMakeAstTest::testFindLibraryBadParse()
 
1302
{
 
1303
    QFETCH( CMakeFunctionDesc, function );
 
1304
    CMakeAst* ast = AstFactory::self()->createAst("find_library");
 
1305
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1306
    delete ast;
 
1307
}
 
1308
 
 
1309
void CMakeAstTest::testFindLibraryBadParse_data()
 
1310
{
 
1311
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1312
    
 
1313
    CMakeFunctionDesc l;
 
1314
    l.name = "lol";
 
1315
    l.addArguments(QString("DEST_VAR name").split(' '));
 
1316
    QTest::newRow("findlib with name") << l;
 
1317
}
 
1318
 
 
1319
 
 
1320
 
 
1321
 
 
1322
 
 
1323
 
 
1324
 
 
1325
 
 
1326
 
 
1327
 
 
1328
void CMakeAstTest::testFindPackageGoodParse()
 
1329
{
 
1330
    TDD_TODO;
 
1331
    QFETCH( CMakeFunctionDesc, function );
 
1332
    CMakeAst* ast = AstFactory::self()->createAst("find_package");
 
1333
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1334
    delete ast;
 
1335
}
 
1336
 
 
1337
void CMakeAstTest::testFindPackageGoodParse_data()
 
1338
{
 
1339
}
 
1340
 
 
1341
void CMakeAstTest::testFindPackageBadParse()
 
1342
{
 
1343
    TDD_TODO;
 
1344
    QFETCH( CMakeFunctionDesc, function );
 
1345
    CMakeAst* ast = AstFactory::self()->createAst("find_package");
 
1346
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1347
    delete ast;
 
1348
}
 
1349
 
 
1350
void CMakeAstTest::testFindPackageBadParse_data()
 
1351
{
 
1352
}
 
1353
 
 
1354
 
 
1355
 
 
1356
 
 
1357
 
 
1358
 
 
1359
 
 
1360
 
 
1361
 
 
1362
 
 
1363
void CMakeAstTest::testFindPathGoodParse()
 
1364
{
 
1365
    TDD_TODO;
 
1366
    QFETCH( CMakeFunctionDesc, function );
 
1367
    CMakeAst* ast = AstFactory::self()->createAst("find_path");
 
1368
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1369
    delete ast;
 
1370
}
 
1371
 
 
1372
void CMakeAstTest::testFindPathGoodParse_data()
 
1373
{
 
1374
}
 
1375
 
 
1376
void CMakeAstTest::testFindPathBadParse()
 
1377
{
 
1378
    TDD_TODO;
 
1379
    QFETCH( CMakeFunctionDesc, function );
 
1380
    CMakeAst* ast = AstFactory::self()->createAst("find_path");
 
1381
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1382
    delete ast;
 
1383
}
 
1384
 
 
1385
void CMakeAstTest::testFindPathBadParse_data()
 
1386
{
 
1387
}
 
1388
 
 
1389
 
 
1390
 
 
1391
 
 
1392
 
 
1393
 
 
1394
 
 
1395
 
 
1396
 
 
1397
 
 
1398
void CMakeAstTest::testFindProgramGoodParse()
 
1399
{
 
1400
    QFETCH( CMakeFunctionDesc, function );
 
1401
    CMakeAst* ast = AstFactory::self()->createAst("find_program");
 
1402
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1403
    delete ast;
 
1404
}
 
1405
 
 
1406
void CMakeAstTest::testFindProgramGoodParse_data()
 
1407
{
 
1408
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1409
 
 
1410
    CMakeFunctionDesc l;
 
1411
    l.name = "find_program";
 
1412
    l.addArguments(QStringList() << "MY_VAR" << "file" << "location");
 
1413
    QTest::newRow("normal use") << l;
 
1414
 
 
1415
    l.arguments.clear();
 
1416
    l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "file1" << "file2" << "PATHS" << "location1" << "location2");
 
1417
    QTest::newRow("advanced use") << l;
 
1418
 
 
1419
    l.arguments.clear();
 
1420
    l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "file1" << "file2"
 
1421
            << "PATHS" << "location1" << "location2" << "DOC" << "I am documenting"
 
1422
            << "PATH_SUFFIXES" << "modules" << "NO_CMAKE_PATH");
 
1423
    QTest::newRow("strange use") << l;
 
1424
}
 
1425
 
 
1426
void CMakeAstTest::testFindProgramBadParse()
 
1427
{
 
1428
    QFETCH( CMakeFunctionDesc, function );
 
1429
    CMakeAst* ast = AstFactory::self()->createAst("find_program");
 
1430
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1431
    delete ast;
 
1432
}
 
1433
 
 
1434
void CMakeAstTest::testFindProgramBadParse_data()
 
1435
{
 
1436
    
 
1437
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1438
    
 
1439
    CMakeFunctionDesc l;
 
1440
    l.name = "";
 
1441
    l.addArguments(QStringList() << "MY_VAR" << "file");
 
1442
    QTest::newRow ("no function name") << l;
 
1443
 
 
1444
    l.arguments.clear();
 
1445
    l.name = "find_program";
 
1446
    l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "PATHS" << "location1" << "location2");
 
1447
    QTest::newRow("no names") << l;
 
1448
}
 
1449
 
 
1450
 
 
1451
 
 
1452
 
 
1453
 
 
1454
 
 
1455
 
 
1456
 
 
1457
 
 
1458
 
 
1459
void CMakeAstTest::testFltkWrapUiGoodParse()
 
1460
{
 
1461
    TDD_TODO;
 
1462
    QFETCH( CMakeFunctionDesc, function );
 
1463
    CMakeAst* ast = AstFactory::self()->createAst("fltk_wrap_ui");
 
1464
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1465
    delete ast;
 
1466
}
 
1467
 
 
1468
void CMakeAstTest::testFltkWrapUiGoodParse_data()
 
1469
{
 
1470
}
 
1471
 
 
1472
void CMakeAstTest::testFltkWrapUiBadParse()
 
1473
{
 
1474
    TDD_TODO;
 
1475
    QFETCH( CMakeFunctionDesc, function );
 
1476
    CMakeAst* ast = AstFactory::self()->createAst("fltk_wrap_ui");
 
1477
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1478
    delete ast;
 
1479
}
 
1480
 
 
1481
void CMakeAstTest::testFltkWrapUiBadParse_data()
 
1482
{
 
1483
}
 
1484
 
 
1485
 
 
1486
 
 
1487
 
 
1488
 
 
1489
 
 
1490
 
 
1491
 
 
1492
 
 
1493
 
 
1494
void CMakeAstTest::testForeachGoodParse()
 
1495
{
 
1496
    TDD_TODO;
 
1497
    QFETCH( CMakeFunctionDesc, function );
 
1498
    CMakeAst* ast = AstFactory::self()->createAst("foreach");
 
1499
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1500
    delete ast;
 
1501
}
 
1502
 
 
1503
void CMakeAstTest::testForeachGoodParse_data()
 
1504
{
 
1505
}
 
1506
 
 
1507
void CMakeAstTest::testForeachBadParse()
 
1508
{
 
1509
    TDD_TODO;
 
1510
    QFETCH( CMakeFunctionDesc, function );
 
1511
    CMakeAst* ast = AstFactory::self()->createAst("foreach");
 
1512
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1513
    delete ast;
 
1514
}
 
1515
 
 
1516
void CMakeAstTest::testForeachBadParse_data()
 
1517
{
 
1518
}
 
1519
 
 
1520
 
 
1521
 
 
1522
 
 
1523
 
 
1524
 
 
1525
 
 
1526
 
 
1527
 
 
1528
 
 
1529
 
 
1530
void CMakeAstTest::testGetCMakePropertyGoodParse()
 
1531
{
 
1532
    TDD_TODO;
 
1533
    QFETCH( CMakeFunctionDesc, function );
 
1534
    CMakeAst* ast = AstFactory::self()->createAst("get_cmake_property");
 
1535
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1536
    delete ast;
 
1537
}
 
1538
 
 
1539
void CMakeAstTest::testGetCMakePropertyGoodParse_data()
 
1540
{
 
1541
}
 
1542
 
 
1543
void CMakeAstTest::testGetCMakePropertyBadParse()
 
1544
{
 
1545
    TDD_TODO;
 
1546
    QFETCH( CMakeFunctionDesc, function );
 
1547
    CMakeAst* ast = AstFactory::self()->createAst("get_cmake_property");
 
1548
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1549
    delete ast;
 
1550
}
 
1551
 
 
1552
void CMakeAstTest::testGetCMakePropertyBadParse_data()
 
1553
{
 
1554
}
 
1555
 
 
1556
 
 
1557
 
 
1558
 
 
1559
 
 
1560
 
 
1561
 
 
1562
 
 
1563
 
 
1564
 
 
1565
void CMakeAstTest::testGetDirPropertyGoodParse()
 
1566
{
 
1567
    TDD_TODO;
 
1568
    QFETCH( CMakeFunctionDesc, function );
 
1569
    CMakeAst* ast = AstFactory::self()->createAst("get_directory_property");
 
1570
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1571
    delete ast;
 
1572
}
 
1573
 
 
1574
void CMakeAstTest::testGetDirPropertyGoodParse_data()
 
1575
{
 
1576
}
 
1577
 
 
1578
void CMakeAstTest::testGetDirPropertyBadParse()
 
1579
{
 
1580
    TDD_TODO;
 
1581
    QFETCH( CMakeFunctionDesc, function );
 
1582
    CMakeAst* ast = AstFactory::self()->createAst("get_directory_property");
 
1583
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1584
    delete ast;
 
1585
}
 
1586
 
 
1587
void CMakeAstTest::testGetDirPropertyBadParse_data()
 
1588
{
 
1589
}
 
1590
 
 
1591
 
 
1592
 
 
1593
 
 
1594
 
 
1595
 
 
1596
 
 
1597
 
 
1598
 
 
1599
 
 
1600
void CMakeAstTest::testGetFilenameComponentGoodParse()
 
1601
{
 
1602
    TDD_TODO;
 
1603
    QFETCH( CMakeFunctionDesc, function );
 
1604
    CMakeAst* ast = AstFactory::self()->createAst("get_filename_component");
 
1605
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1606
    delete ast;
 
1607
}
 
1608
 
 
1609
void CMakeAstTest::testGetFilenameComponentGoodParse_data()
 
1610
{
 
1611
}
 
1612
 
 
1613
void CMakeAstTest::testGetFilenameComponentBadParse()
 
1614
{
 
1615
    TDD_TODO;
 
1616
    QFETCH( CMakeFunctionDesc, function );
 
1617
    CMakeAst* ast = AstFactory::self()->createAst("get_filename_component");
 
1618
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1619
    delete ast;
 
1620
}
 
1621
 
 
1622
void CMakeAstTest::testGetFilenameComponentBadParse_data()
 
1623
{
 
1624
}
 
1625
 
 
1626
 
 
1627
 
 
1628
 
 
1629
 
 
1630
 
 
1631
 
 
1632
 
 
1633
 
 
1634
 
 
1635
void CMakeAstTest::testGetSourceFilePropGoodParse()
 
1636
{
 
1637
    TDD_TODO;
 
1638
    QFETCH( CMakeFunctionDesc, function );
 
1639
    CMakeAst* ast = AstFactory::self()->createAst("get_sourcefile_property");
 
1640
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1641
    delete ast;
 
1642
}
 
1643
 
 
1644
void CMakeAstTest::testGetSourceFilePropGoodParse_data()
 
1645
{
 
1646
}
 
1647
 
 
1648
void CMakeAstTest::testGetSourceFilePropBadParse()
 
1649
{
 
1650
    TDD_TODO;
 
1651
    QFETCH( CMakeFunctionDesc, function );
 
1652
    CMakeAst* ast = AstFactory::self()->createAst("get_sourcefile_property");
 
1653
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1654
    delete ast;
 
1655
}
 
1656
 
 
1657
void CMakeAstTest::testGetSourceFilePropBadParse_data()
 
1658
{
 
1659
}
 
1660
 
 
1661
 
 
1662
 
 
1663
 
 
1664
 
 
1665
 
 
1666
 
 
1667
 
 
1668
 
 
1669
 
 
1670
void CMakeAstTest::testGetTargetPropGoodParse()
 
1671
{
 
1672
    TDD_TODO;
 
1673
    QFETCH( CMakeFunctionDesc, function );
 
1674
    CMakeAst* ast = AstFactory::self()->createAst("get_target_property");
 
1675
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1676
    delete ast;
 
1677
}
 
1678
 
 
1679
void CMakeAstTest::testGetTargetPropGoodParse_data()
 
1680
{
 
1681
}
 
1682
 
 
1683
void CMakeAstTest::testGetTargetPropBadParse()
 
1684
{
 
1685
    TDD_TODO;
 
1686
    QFETCH( CMakeFunctionDesc, function );
 
1687
    CMakeAst* ast = AstFactory::self()->createAst("get_target_property");
 
1688
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1689
    delete ast;
 
1690
}
 
1691
 
 
1692
void CMakeAstTest::testGetTargetPropBadParse_data()
 
1693
{
 
1694
}
 
1695
 
 
1696
 
 
1697
 
 
1698
 
 
1699
 
 
1700
 
 
1701
 
 
1702
 
 
1703
 
 
1704
 
 
1705
void CMakeAstTest::testGetTestPropGoodParse()
 
1706
{
 
1707
    TDD_TODO;
 
1708
    QFETCH( CMakeFunctionDesc, function );
 
1709
    CMakeAst* ast = AstFactory::self()->createAst("get_test_property");
 
1710
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1711
    delete ast;
 
1712
}
 
1713
 
 
1714
void CMakeAstTest::testGetTestPropGoodParse_data()
 
1715
{
 
1716
}
 
1717
 
 
1718
void CMakeAstTest::testGetTestPropBadParse()
 
1719
{
 
1720
    TDD_TODO;
 
1721
    QFETCH( CMakeFunctionDesc, function );
 
1722
    CMakeAst* ast = AstFactory::self()->createAst("get_test_property");
 
1723
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1724
    delete ast;
 
1725
}
 
1726
 
 
1727
void CMakeAstTest::testGetTestPropBadParse_data()
 
1728
{
 
1729
}
 
1730
 
 
1731
 
 
1732
 
 
1733
 
 
1734
 
 
1735
 
 
1736
 
 
1737
 
 
1738
 
 
1739
 
 
1740
void CMakeAstTest::testIfGoodParse()
 
1741
{
 
1742
    TDD_TODO;
 
1743
    QFETCH( CMakeFunctionDesc, function );
 
1744
    CMakeAst* ast = AstFactory::self()->createAst("if");
 
1745
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1746
    delete ast;
 
1747
}
 
1748
 
 
1749
void CMakeAstTest::testIfGoodParse_data()
 
1750
{
 
1751
}
 
1752
 
 
1753
void CMakeAstTest::testIfBadParse()
 
1754
{
 
1755
    TDD_TODO;
 
1756
    QFETCH( CMakeFunctionDesc, function );
 
1757
    CMakeAst* ast = AstFactory::self()->createAst("if");
 
1758
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1759
    delete ast;
 
1760
}
 
1761
 
 
1762
void CMakeAstTest::testIfBadParse_data()
 
1763
{
 
1764
}
 
1765
 
 
1766
 
 
1767
 
 
1768
 
 
1769
 
 
1770
 
 
1771
 
 
1772
 
 
1773
 
 
1774
 
 
1775
void CMakeAstTest::testIncludeGoodParse()
 
1776
{
 
1777
    QFETCH( CMakeFunctionDesc, function );
 
1778
    CMakeAst* ast = AstFactory::self()->createAst("include");
 
1779
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1780
    delete ast;
 
1781
}
 
1782
 
 
1783
void CMakeAstTest::testIncludeGoodParse_data()
 
1784
{
 
1785
    CMakeFunctionDesc func1, func2, func3, func4, func5;
 
1786
    func1.name = "INCLUDE";
 
1787
    func2.name = func3.name = func4.name = func5.name = func1.name.toLower();
 
1788
 
 
1789
    QStringList argList1, argList2, argList3, argList4;
 
1790
    argList1 << "SomeFile";
 
1791
    argList2 << "SomeFile" << "OPTIONAL";
 
1792
    argList3 << "SomeFile" << "RESULT_VARIABLE" << "output";
 
1793
    argList4 << "SomeFile" << "OPTIONAL" << "RESULT_VARIABLE" << "output";
 
1794
 
 
1795
    func1.addArguments( argList1 );
 
1796
    func2.addArguments( argList1 );
 
1797
    func3.addArguments( argList2 );
 
1798
    func4.addArguments( argList3 );
 
1799
    func5.addArguments( argList4 );
 
1800
 
 
1801
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1802
    QTest::newRow( "good upper" ) << func1;
 
1803
    QTest::newRow( "good lower" ) << func2;
 
1804
    QTest::newRow( "good optional" ) << func3;
 
1805
    QTest::newRow( "good result" ) << func4;
 
1806
    QTest::newRow( "good all args" ) << func5;
 
1807
}
 
1808
 
 
1809
void CMakeAstTest::testIncludeBadParse()
 
1810
{
 
1811
    QFETCH( CMakeFunctionDesc, function );
 
1812
    CMakeAst* ast = AstFactory::self()->createAst("include");
 
1813
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1814
    delete ast;
 
1815
}
 
1816
 
 
1817
void CMakeAstTest::testIncludeBadParse_data()
 
1818
{
 
1819
    CMakeFunctionDesc func1, func2;
 
1820
    func1.name = "WrongFuncName";
 
1821
    func2.name = "include";
 
1822
 
 
1823
    QStringList argList1, argList2;
 
1824
    argList1 << "SomeFile";
 
1825
 
 
1826
    func1.addArguments( argList1 );
 
1827
    func2.addArguments( argList2 );
 
1828
 
 
1829
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
1830
    QTest::newRow( "bad wrong name" ) << func1;
 
1831
    QTest::newRow( "bad no args" ) << func2;
 
1832
 
 
1833
}
 
1834
 
 
1835
 
 
1836
 
 
1837
 
 
1838
 
 
1839
 
 
1840
 
 
1841
 
 
1842
 
 
1843
 
 
1844
void CMakeAstTest::testIncludeDirectoriesGoodParse()
 
1845
{
 
1846
    QFETCH( CMakeFunctionDesc, function );
 
1847
    CMakeAst* ast = AstFactory::self()->createAst("include_directories");
 
1848
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1849
    delete ast;
 
1850
}
 
1851
 
 
1852
void CMakeAstTest::testIncludeDirectoriesGoodParse_data()
 
1853
{
 
1854
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1855
    
 
1856
    CMakeFunctionDesc l;
 
1857
    l.name = "include_directories";
 
1858
    l.addArguments(QStringList() << "../g4u");
 
1859
    QTest::newRow("a normal include_directories") << l;
 
1860
    
 
1861
    l.arguments.clear();
 
1862
    l.addArguments(QStringList() << "AFTER" << "boost/");
 
1863
    QTest::newRow("a include_directories with AFTER parameter") << l;
 
1864
    
 
1865
    l.arguments.clear();
 
1866
    l.addArguments(QStringList() << "SYSTEM" << "~/kdelibs");
 
1867
    QTest::newRow("a include_directories with SYSTEM paremeter") << l;
 
1868
}
 
1869
 
 
1870
void CMakeAstTest::testIncludeDirectoriesBadParse()
 
1871
{
 
1872
    QFETCH( CMakeFunctionDesc, function );
 
1873
    CMakeAst* ast = AstFactory::self()->createAst("include_directories");
 
1874
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1875
    delete ast;
 
1876
}
 
1877
 
 
1878
void CMakeAstTest::testIncludeDirectoriesBadParse_data()
 
1879
{
 
1880
    QTest::addColumn<CMakeFunctionDesc>("function");
 
1881
    
 
1882
    CMakeFunctionDesc l;
 
1883
    l.name = "include_directories";
 
1884
    l.addArguments(QStringList() << "AFTER" << "BEFORE" << "lol");
 
1885
    QTest::newRow("can't have after and before in include_directories") << l;
 
1886
}
 
1887
 
 
1888
 
 
1889
 
 
1890
 
 
1891
 
 
1892
 
 
1893
 
 
1894
 
 
1895
 
 
1896
 
 
1897
void CMakeAstTest::testIncludeExternalMsProjectGoodParse()
 
1898
{
 
1899
    TDD_TODO;
 
1900
    QFETCH( CMakeFunctionDesc, function );
 
1901
    CMakeAst* ast = AstFactory::self()->createAst("include_external_msproject");
 
1902
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1903
    delete ast;
 
1904
}
 
1905
 
 
1906
void CMakeAstTest::testIncludeExternalMsProjectGoodParse_data()
 
1907
{
 
1908
}
 
1909
 
 
1910
void CMakeAstTest::testIncludeExternalMsProjectBadParse()
 
1911
{
 
1912
    TDD_TODO;
 
1913
    QFETCH( CMakeFunctionDesc, function );
 
1914
    CMakeAst* ast = AstFactory::self()->createAst("include_external_msproject");
 
1915
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1916
    delete ast;
 
1917
}
 
1918
 
 
1919
void CMakeAstTest::testIncludeExternalMsProjectBadParse_data()
 
1920
{
 
1921
}
 
1922
 
 
1923
 
 
1924
 
 
1925
 
 
1926
 
 
1927
 
 
1928
 
 
1929
 
 
1930
 
 
1931
 
 
1932
void CMakeAstTest::testIncludeRegularExpressionGoodParse()
 
1933
{
 
1934
    TDD_TODO;
 
1935
    QFETCH( CMakeFunctionDesc, function );
 
1936
    CMakeAst* ast = AstFactory::self()->createAst("include_regular_expression");
 
1937
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1938
    delete ast;
 
1939
}
 
1940
 
 
1941
void CMakeAstTest::testIncludeRegularExpressionGoodParse_data()
 
1942
{
 
1943
}
 
1944
 
 
1945
void CMakeAstTest::testIncludeRegularExpressionBadParse()
 
1946
{
 
1947
    TDD_TODO;
 
1948
    QFETCH( CMakeFunctionDesc, function );
 
1949
    CMakeAst* ast = AstFactory::self()->createAst("include_regular_expression");
 
1950
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1951
    delete ast;
 
1952
}
 
1953
 
 
1954
void CMakeAstTest::testIncludeRegularExpressionBadParse_data()
 
1955
{
 
1956
}
 
1957
 
 
1958
 
 
1959
 
 
1960
 
 
1961
 
 
1962
 
 
1963
 
 
1964
 
 
1965
 
 
1966
 
 
1967
void CMakeAstTest::testInstallGoodParse()
 
1968
{
 
1969
    TDD_TODO;
 
1970
    QFETCH( CMakeFunctionDesc, function );
 
1971
    CMakeAst* ast = AstFactory::self()->createAst("install");
 
1972
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
1973
    delete ast;
 
1974
}
 
1975
 
 
1976
void CMakeAstTest::testInstallGoodParse_data()
 
1977
{
 
1978
}
 
1979
 
 
1980
void CMakeAstTest::testInstallBadParse()
 
1981
{
 
1982
    TDD_TODO;
 
1983
    QFETCH( CMakeFunctionDesc, function );
 
1984
    CMakeAst* ast = AstFactory::self()->createAst("install");
 
1985
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
1986
    delete ast;
 
1987
}
 
1988
 
 
1989
void CMakeAstTest::testInstallBadParse_data()
 
1990
{
 
1991
}
 
1992
 
 
1993
 
 
1994
 
 
1995
 
 
1996
 
 
1997
 
 
1998
 
 
1999
 
 
2000
 
 
2001
 
 
2002
void CMakeAstTest::testInstallFilesGoodParse()
 
2003
{
 
2004
    TDD_TODO;
 
2005
    QFETCH( CMakeFunctionDesc, function );
 
2006
    CMakeAst* ast = AstFactory::self()->createAst("install_files");
 
2007
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2008
    delete ast;
 
2009
}
 
2010
 
 
2011
void CMakeAstTest::testInstallFilesGoodParse_data()
 
2012
{
 
2013
}
 
2014
 
 
2015
void CMakeAstTest::testInstallFilesBadParse()
 
2016
{
 
2017
    TDD_TODO;
 
2018
    QFETCH( CMakeFunctionDesc, function );
 
2019
    CMakeAst* ast = AstFactory::self()->createAst("install_files");
 
2020
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2021
    delete ast;
 
2022
}
 
2023
 
 
2024
void CMakeAstTest::testInstallFilesBadParse_data()
 
2025
{
 
2026
}
 
2027
 
 
2028
 
 
2029
 
 
2030
 
 
2031
 
 
2032
 
 
2033
 
 
2034
 
 
2035
 
 
2036
 
 
2037
void CMakeAstTest::testInstallProgramsGoodParse()
 
2038
{
 
2039
    TDD_TODO;
 
2040
    QFETCH( CMakeFunctionDesc, function );
 
2041
    CMakeAst* ast = AstFactory::self()->createAst("install_programs");
 
2042
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2043
    delete ast;
 
2044
}
 
2045
 
 
2046
void CMakeAstTest::testInstallProgramsGoodParse_data()
 
2047
{
 
2048
}
 
2049
 
 
2050
void CMakeAstTest::testInstallProgramsBadParse()
 
2051
{
 
2052
    TDD_TODO;
 
2053
    QFETCH( CMakeFunctionDesc, function );
 
2054
    CMakeAst* ast = AstFactory::self()->createAst("install_programs");
 
2055
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2056
    delete ast;
 
2057
}
 
2058
 
 
2059
void CMakeAstTest::testInstallProgramsBadParse_data()
 
2060
{
 
2061
}
 
2062
 
 
2063
 
 
2064
 
 
2065
 
 
2066
 
 
2067
 
 
2068
 
 
2069
 
 
2070
 
 
2071
 
 
2072
void CMakeAstTest::testInstallTargetsGoodParse()
 
2073
{
 
2074
    TDD_TODO;
 
2075
    QFETCH( CMakeFunctionDesc, function );
 
2076
    CMakeAst* ast = AstFactory::self()->createAst("install_targets");
 
2077
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2078
    delete ast;
 
2079
}
 
2080
 
 
2081
void CMakeAstTest::testInstallTargetsGoodParse_data()
 
2082
{
 
2083
}
 
2084
 
 
2085
void CMakeAstTest::testInstallTargetsBadParse()
 
2086
{
 
2087
    TDD_TODO;
 
2088
    QFETCH( CMakeFunctionDesc, function );
 
2089
    CMakeAst* ast = AstFactory::self()->createAst("install_targets");
 
2090
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2091
    delete ast;
 
2092
}
 
2093
 
 
2094
void CMakeAstTest::testInstallTargetsBadParse_data()
 
2095
{
 
2096
}
 
2097
 
 
2098
 
 
2099
 
 
2100
 
 
2101
 
 
2102
 
 
2103
 
 
2104
 
 
2105
 
 
2106
 
 
2107
void CMakeAstTest::testLinkDirectoriesGoodParse()
 
2108
{
 
2109
    TDD_TODO;
 
2110
    QFETCH( CMakeFunctionDesc, function );
 
2111
    CMakeAst* ast = AstFactory::self()->createAst("link_directories");
 
2112
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2113
    delete ast;
 
2114
}
 
2115
 
 
2116
void CMakeAstTest::testLinkDirectoriesGoodParse_data()
 
2117
{
 
2118
}
 
2119
 
 
2120
void CMakeAstTest::testLinkDirectoriesBadParse()
 
2121
{
 
2122
    TDD_TODO;
 
2123
    QFETCH( CMakeFunctionDesc, function );
 
2124
    CMakeAst* ast = AstFactory::self()->createAst("link_directories");
 
2125
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2126
    delete ast;
 
2127
}
 
2128
 
 
2129
void CMakeAstTest::testLinkDirectoriesBadParse_data()
 
2130
{
 
2131
}
 
2132
 
 
2133
 
 
2134
 
 
2135
 
 
2136
 
 
2137
 
 
2138
 
 
2139
 
 
2140
 
 
2141
 
 
2142
void CMakeAstTest::testLinkLibrariesGoodParse()
 
2143
{
 
2144
    TDD_TODO;
 
2145
    QFETCH( CMakeFunctionDesc, function );
 
2146
    CMakeAst* ast = AstFactory::self()->createAst("link_libraries");
 
2147
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2148
    delete ast;
 
2149
}
 
2150
 
 
2151
void CMakeAstTest::testLinkLibrariesGoodParse_data()
 
2152
{
 
2153
}
 
2154
 
 
2155
void CMakeAstTest::testLinkLibrariesBadParse()
 
2156
{
 
2157
    TDD_TODO;
 
2158
    QFETCH( CMakeFunctionDesc, function );
 
2159
    CMakeAst* ast = AstFactory::self()->createAst("link_libraries");
 
2160
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2161
    delete ast;
 
2162
}
 
2163
 
 
2164
void CMakeAstTest::testLinkLibrariesBadParse_data()
 
2165
{
 
2166
}
 
2167
 
 
2168
 
 
2169
 
 
2170
 
 
2171
 
 
2172
 
 
2173
 
 
2174
 
 
2175
 
 
2176
 
 
2177
void CMakeAstTest::testListGoodParse()
 
2178
{
 
2179
    TDD_TODO;
 
2180
    QFETCH( CMakeFunctionDesc, function );
 
2181
    CMakeAst* ast = AstFactory::self()->createAst("list");
 
2182
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2183
    delete ast;
 
2184
}
 
2185
 
 
2186
void CMakeAstTest::testListGoodParse_data()
 
2187
{
 
2188
}
 
2189
 
 
2190
void CMakeAstTest::testListBadParse()
 
2191
{
 
2192
    TDD_TODO;
 
2193
    QFETCH( CMakeFunctionDesc, function );
 
2194
    CMakeAst* ast = AstFactory::self()->createAst("list");
 
2195
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2196
    delete ast;
 
2197
}
 
2198
 
 
2199
void CMakeAstTest::testListBadParse_data()
 
2200
{
 
2201
}
 
2202
 
 
2203
 
 
2204
 
 
2205
 
 
2206
 
 
2207
 
 
2208
 
 
2209
 
 
2210
 
 
2211
 
 
2212
void CMakeAstTest::testLoadCacheGoodParse()
 
2213
{
 
2214
    TDD_TODO;
 
2215
    QFETCH( CMakeFunctionDesc, function );
 
2216
    CMakeAst* ast = AstFactory::self()->createAst("load_cache");
 
2217
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2218
    delete ast;
 
2219
}
 
2220
 
 
2221
void CMakeAstTest::testLoadCacheGoodParse_data()
 
2222
{
 
2223
}
 
2224
 
 
2225
void CMakeAstTest::testLoadCacheBadParse()
 
2226
{
 
2227
    TDD_TODO;
 
2228
    QFETCH( CMakeFunctionDesc, function );
 
2229
    CMakeAst* ast = AstFactory::self()->createAst("load_cache");
 
2230
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2231
    delete ast;
 
2232
}
 
2233
 
 
2234
void CMakeAstTest::testLoadCacheBadParse_data()
 
2235
{
 
2236
}
 
2237
 
 
2238
 
 
2239
 
 
2240
 
 
2241
 
 
2242
 
 
2243
 
 
2244
 
 
2245
 
 
2246
 
 
2247
void CMakeAstTest::testLoadCommandGoodParse()
 
2248
{
 
2249
    TDD_TODO;
 
2250
    QFETCH( CMakeFunctionDesc, function );
 
2251
    CMakeAst* ast = AstFactory::self()->createAst("load_command");
 
2252
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2253
    delete ast;
 
2254
}
 
2255
 
 
2256
void CMakeAstTest::testLoadCommandGoodParse_data()
 
2257
{
 
2258
}
 
2259
 
 
2260
void CMakeAstTest::testLoadCommandBadParse()
 
2261
{
 
2262
    TDD_TODO;
 
2263
    QFETCH( CMakeFunctionDesc, function );
 
2264
    CMakeAst* ast = AstFactory::self()->createAst("load_command");
 
2265
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2266
    delete ast;
 
2267
}
 
2268
 
 
2269
void CMakeAstTest::testLoadCommandBadParse_data()
 
2270
{
 
2271
}
 
2272
 
 
2273
 
 
2274
 
 
2275
 
 
2276
 
 
2277
 
 
2278
 
 
2279
 
 
2280
 
 
2281
 
 
2282
void CMakeAstTest::testMacroGoodParse()
 
2283
{
 
2284
    QFETCH( CMakeFunctionDesc, function );
 
2285
    CMakeAst* ast = AstFactory::self()->createAst("macro");
 
2286
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2287
    delete ast;
 
2288
}
 
2289
 
 
2290
void CMakeAstTest::testMacroGoodParse_data()
 
2291
{
 
2292
    CMakeFunctionDesc func1, func2, func3;
 
2293
    func1.name = "MACRO";
 
2294
    func2.name = func3.name = func1.name.toLower();
 
2295
 
 
2296
    QStringList argList1, argList2;
 
2297
    argList1 << "MY_NEATO_MACRO";
 
2298
    argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
 
2299
 
 
2300
    func1.addArguments( argList1 );
 
2301
    func2.addArguments( argList1 );
 
2302
    func3.addArguments( argList2 );
 
2303
 
 
2304
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2305
    QTest::newRow( "good upper" ) << func1;
 
2306
    QTest::newRow( "good lower" ) << func2;
 
2307
    QTest::newRow( "good with args" ) << func3;
 
2308
}
 
2309
 
 
2310
void CMakeAstTest::testMacroBadParse()
 
2311
{
 
2312
    QFETCH( CMakeFunctionDesc, function );
 
2313
    CMakeAst* ast = AstFactory::self()->createAst("macro");
 
2314
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2315
    delete ast;
 
2316
}
 
2317
 
 
2318
void CMakeAstTest::testMacroBadParse_data()
 
2319
{
 
2320
    CMakeFunctionDesc func1, func2;
 
2321
    func1.name = "MACRO";
 
2322
    func2.name = "wrong_function";
 
2323
 
 
2324
    QStringList argList1, argList2;
 
2325
    argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
 
2326
 
 
2327
    func1.addArguments( argList1 );
 
2328
    func2.addArguments( argList2 );
 
2329
 
 
2330
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2331
    QTest::newRow( "bad no args" ) << func1;
 
2332
    QTest::newRow( "bad wrong name" ) << func2;
 
2333
}
 
2334
 
 
2335
void CMakeAstTest::testFunctionGoodParse()
 
2336
{
 
2337
    QFETCH( CMakeFunctionDesc, function );
 
2338
    CMakeAst* ast = AstFactory::self()->createAst("function");
 
2339
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2340
    delete ast;
 
2341
}
 
2342
 
 
2343
void CMakeAstTest::testFunctionGoodParse_data()
 
2344
{
 
2345
    CMakeFunctionDesc func1, func2, func3;
 
2346
    func1.name = "FUNCTION";
 
2347
    func2.name = func3.name = func1.name.toLower();
 
2348
 
 
2349
    QStringList argList1, argList2;
 
2350
    argList1 << "MY_NEATO_MACRO";
 
2351
    argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
 
2352
 
 
2353
    func1.addArguments( argList1 );
 
2354
    func2.addArguments( argList1 );
 
2355
    func3.addArguments( argList2 );
 
2356
 
 
2357
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2358
    QTest::newRow( "good upper" ) << func1;
 
2359
    QTest::newRow( "good lower" ) << func2;
 
2360
    QTest::newRow( "good with args" ) << func3;
 
2361
}
 
2362
 
 
2363
void CMakeAstTest::testFunctionBadParse()
 
2364
{
 
2365
    QFETCH( CMakeFunctionDesc, function );
 
2366
    CMakeAst* ast = AstFactory::self()->createAst("macro");
 
2367
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2368
    delete ast;
 
2369
}
 
2370
 
 
2371
void CMakeAstTest::testFunctionBadParse_data()
 
2372
{
 
2373
    CMakeFunctionDesc func1, func2;
 
2374
    func1.name = "FUNCTION";
 
2375
    func2.name = "wrong_function";
 
2376
 
 
2377
    QStringList argList1, argList2;
 
2378
    argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
 
2379
 
 
2380
    func1.addArguments( argList1 );
 
2381
    func2.addArguments( argList2 );
 
2382
 
 
2383
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2384
    QTest::newRow( "bad no args" ) << func1;
 
2385
    QTest::newRow( "bad wrong name" ) << func2;
 
2386
}
 
2387
 
 
2388
 
 
2389
 
 
2390
 
 
2391
 
 
2392
 
 
2393
 
 
2394
 
 
2395
 
 
2396
 
 
2397
void CMakeAstTest::testMakeDirectoryGoodParse()
 
2398
{
 
2399
    TDD_TODO;
 
2400
    QFETCH( CMakeFunctionDesc, function );
 
2401
    CMakeAst* ast = AstFactory::self()->createAst("make_directory");
 
2402
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2403
    delete ast;
 
2404
}
 
2405
 
 
2406
void CMakeAstTest::testMakeDirectoryGoodParse_data()
 
2407
{
 
2408
}
 
2409
 
 
2410
void CMakeAstTest::testMakeDirectoryBadParse()
 
2411
{
 
2412
    TDD_TODO;
 
2413
    QFETCH( CMakeFunctionDesc, function );
 
2414
    CMakeAst* ast = AstFactory::self()->createAst("make_directory");
 
2415
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2416
    delete ast;
 
2417
}
 
2418
 
 
2419
void CMakeAstTest::testMakeDirectoryBadParse_data()
 
2420
{
 
2421
}
 
2422
 
 
2423
 
 
2424
 
 
2425
 
 
2426
 
 
2427
 
 
2428
 
 
2429
 
 
2430
 
 
2431
 
 
2432
void CMakeAstTest::testMarkAsAdvancedGoodParse()
 
2433
{
 
2434
    QFETCH( CMakeFunctionDesc, function );
 
2435
    CMakeAst* ast = AstFactory::self()->createAst("mark_as_advanced");
 
2436
    QCOMPARE( ast->parseFunctionInfo( function ), true );
 
2437
    delete ast;
 
2438
}
 
2439
 
 
2440
void CMakeAstTest::testMarkAsAdvancedGoodParse_data()
 
2441
{
 
2442
    QTest::addColumn<CMakeFunctionDesc>("function");
 
2443
    
 
2444
    CMakeFunctionDesc l;
 
2445
    l.name = "mark_as_advanced";
 
2446
    l.addArguments(QStringList() << "FORCE" << "My_LIBRARY" << "My_INCLUDES");
 
2447
    QTest::newRow("a forced mark_as_advanced") << l;
 
2448
    
 
2449
    l.arguments.clear();
 
2450
    l.addArguments(QStringList() << "CLEAR" << "My_LIB");
 
2451
    QTest::newRow("a clear mark_as_advanced") << l;
 
2452
    
 
2453
    l.arguments.clear();
 
2454
    l.addArguments(QStringList() << "My_LIB");
 
2455
    QTest::newRow("a normal mark_as_advanced") << l;
 
2456
}
 
2457
 
 
2458
void CMakeAstTest::testMarkAsAdvancedBadParse()
 
2459
{
 
2460
    QFETCH( CMakeFunctionDesc, function );
 
2461
    CMakeAst* ast = AstFactory::self()->createAst("mark_as_advanced");
 
2462
    QCOMPARE( ast->parseFunctionInfo( function ), false );
 
2463
    delete ast;
 
2464
}
 
2465
 
 
2466
void CMakeAstTest::testMarkAsAdvancedBadParse_data()
 
2467
{
 
2468
    QTest::addColumn<CMakeFunctionDesc>("function");
 
2469
    
 
2470
    CMakeFunctionDesc l;
 
2471
    l.name = "mark_as_advanced";
 
2472
    QTest::newRow("a mark_as_advanced without parameters") << l;
 
2473
    
 
2474
    l.arguments.clear();
 
2475
    l.addArguments(QStringList() << "CLEAR");
 
2476
    QTest::newRow("a clear mark_as_advanced without parameters") << l;
 
2477
}
 
2478
 
 
2479
 
 
2480
 
 
2481
 
 
2482
 
 
2483
 
 
2484
 
 
2485
 
 
2486
 
 
2487
 
 
2488
void CMakeAstTest::testMathGoodParse()
 
2489
{
 
2490
    TDD_TODO;
 
2491
    QFETCH( CMakeFunctionDesc, function );
 
2492
    CMakeAst* ast = AstFactory::self()->createAst("math");
 
2493
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2494
    delete ast;
 
2495
}
 
2496
 
 
2497
void CMakeAstTest::testMathGoodParse_data()
 
2498
{
 
2499
}
 
2500
 
 
2501
void CMakeAstTest::testMathBadParse()
 
2502
{
 
2503
    TDD_TODO;
 
2504
    QFETCH( CMakeFunctionDesc, function );
 
2505
    CMakeAst* ast = AstFactory::self()->createAst("math");
 
2506
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2507
    delete ast;
 
2508
}
 
2509
 
 
2510
void CMakeAstTest::testMathBadParse_data()
 
2511
{
 
2512
}
 
2513
 
 
2514
 
 
2515
 
 
2516
 
 
2517
 
 
2518
 
 
2519
 
 
2520
 
 
2521
 
 
2522
 
 
2523
 
 
2524
void CMakeAstTest::testMessageGoodParse()
 
2525
{
 
2526
    TDD_TODO;
 
2527
    QFETCH( CMakeFunctionDesc, function );
 
2528
    CMakeAst* ast = AstFactory::self()->createAst("message");
 
2529
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2530
    delete ast;
 
2531
}
 
2532
 
 
2533
void CMakeAstTest::testMessageGoodParse_data()
 
2534
{
 
2535
}
 
2536
 
 
2537
void CMakeAstTest::testMessageBadParse()
 
2538
{
 
2539
    TDD_TODO;
 
2540
    QFETCH( CMakeFunctionDesc, function );
 
2541
    CMakeAst* ast = AstFactory::self()->createAst("message");
 
2542
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2543
    delete ast;
 
2544
}
 
2545
 
 
2546
void CMakeAstTest::testMessageBadParse_data()
 
2547
{
 
2548
}
 
2549
 
 
2550
 
 
2551
 
 
2552
 
 
2553
 
 
2554
 
 
2555
 
 
2556
 
 
2557
 
 
2558
 
 
2559
void CMakeAstTest::testOptionGoodParse()
 
2560
{
 
2561
    TDD_TODO;
 
2562
    QFETCH( CMakeFunctionDesc, function );
 
2563
    CMakeAst* ast = AstFactory::self()->createAst("option");
 
2564
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2565
    delete ast;
 
2566
}
 
2567
 
 
2568
void CMakeAstTest::testOptionGoodParse_data()
 
2569
{
 
2570
}
 
2571
 
 
2572
void CMakeAstTest::testOptionBadParse()
 
2573
{
 
2574
    TDD_TODO;
 
2575
    QFETCH( CMakeFunctionDesc, function );
 
2576
    CMakeAst* ast = AstFactory::self()->createAst("option");
 
2577
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2578
    delete ast;
 
2579
}
 
2580
 
 
2581
void CMakeAstTest::testOptionBadParse_data()
 
2582
{
 
2583
}
 
2584
 
 
2585
 
 
2586
 
 
2587
 
 
2588
 
 
2589
 
 
2590
 
 
2591
 
 
2592
 
 
2593
 
 
2594
void CMakeAstTest::testOutputRequiredFilesGoodParse()
 
2595
{
 
2596
    TDD_TODO;
 
2597
    QFETCH( CMakeFunctionDesc, function );
 
2598
    CMakeAst* ast = AstFactory::self()->createAst("output_required_files");
 
2599
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2600
    delete ast;
 
2601
}
 
2602
 
 
2603
void CMakeAstTest::testOutputRequiredFilesGoodParse_data()
 
2604
{
 
2605
}
 
2606
 
 
2607
void CMakeAstTest::testOutputRequiredFilesBadParse()
 
2608
{
 
2609
    TDD_TODO;
 
2610
    QFETCH( CMakeFunctionDesc, function );
 
2611
    CMakeAst* ast = AstFactory::self()->createAst("output_required_files");
 
2612
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2613
    delete ast;
 
2614
}
 
2615
 
 
2616
void CMakeAstTest::testOutputRequiredFilesBadParse_data()
 
2617
{
 
2618
}
 
2619
 
 
2620
 
 
2621
 
 
2622
 
 
2623
 
 
2624
 
 
2625
 
 
2626
 
 
2627
 
 
2628
 
 
2629
void CMakeAstTest::testProjectGoodParse()
 
2630
{
 
2631
    QFETCH( CMakeFunctionDesc, function );
 
2632
    CMakeAst* ast = AstFactory::self()->createAst("project");
 
2633
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2634
    delete ast;
 
2635
}
 
2636
 
 
2637
void CMakeAstTest::testProjectGoodParse_data()
 
2638
{
 
2639
    CMakeFunctionDesc func1, func2, func3, func4, func5, func6;
 
2640
    func1.name = "PROJECT";
 
2641
    func2.name = func3.name = func4.name = func5.name = func6.name = func1.name.toLower();
 
2642
 
 
2643
    QStringList argList1, argList2, argList3, argList4, argList5;
 
2644
    argList1 << "myproject";
 
2645
    argList2 << "myproject" << "C";
 
2646
    argList3 << "myproject" << "CXX";
 
2647
    argList4 << "myproject" << "Java";
 
2648
    argList5 << "myproject" << "C" << "CXX" << "Java";
 
2649
 
 
2650
    func1.addArguments( argList1 );
 
2651
    func2.addArguments( argList1 );
 
2652
    func3.addArguments( argList2 );
 
2653
    func4.addArguments( argList3 );
 
2654
    func5.addArguments( argList4 );
 
2655
    func6.addArguments( argList5 );
 
2656
 
 
2657
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2658
    QTest::newRow( "good 1" ) << func1;
 
2659
    QTest::newRow( "good 2" ) << func2;
 
2660
    QTest::newRow( "good 3" ) << func3;
 
2661
    QTest::newRow( "good 4" ) << func4;
 
2662
    QTest::newRow( "good 5" ) << func5;
 
2663
    QTest::newRow( "good 6" ) << func6;
 
2664
 
 
2665
}
 
2666
 
 
2667
void CMakeAstTest::testProjectBadParse()
 
2668
{
 
2669
    QFETCH( CMakeFunctionDesc, function );
 
2670
    CMakeAst* ast = AstFactory::self()->createAst("project");
 
2671
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2672
    delete ast;
 
2673
}
 
2674
 
 
2675
void CMakeAstTest::testProjectBadParse_data()
 
2676
{
 
2677
    CMakeFunctionDesc func1, func2, func3;
 
2678
    func1.name = "wrongname";
 
2679
    func2.name = func3.name = "PROJECT";
 
2680
 
 
2681
    QStringList argList1, argList2;
 
2682
    argList1 << "myproject" << "C" << "CXX" << "Java";
 
2683
    argList2 << "myproject" << "C" << "CXX" << "Java" << "foo";
 
2684
 
 
2685
    func1.addArguments( argList1 );
 
2686
    func3.addArguments( argList2 );
 
2687
 
 
2688
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2689
    QTest::newRow("wrong name") << func1;
 
2690
    QTest::newRow("no args") << func2;
 
2691
    QTest::newRow("wrong lang args") << func3;
 
2692
}
 
2693
 
 
2694
 
 
2695
 
 
2696
 
 
2697
 
 
2698
 
 
2699
 
 
2700
 
 
2701
 
 
2702
 
 
2703
void CMakeAstTest::testQtWrapCppGoodParse()
 
2704
{
 
2705
    TDD_TODO;
 
2706
    QFETCH( CMakeFunctionDesc, function );
 
2707
    CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_cpp");
 
2708
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2709
    delete ast;
 
2710
}
 
2711
 
 
2712
void CMakeAstTest::testQtWrapCppGoodParse_data()
 
2713
{
 
2714
}
 
2715
 
 
2716
void CMakeAstTest::testQtWrapCppBadParse()
 
2717
{
 
2718
    TDD_TODO;
 
2719
    QFETCH( CMakeFunctionDesc, function );
 
2720
    CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_cpp");
 
2721
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2722
    delete ast;
 
2723
}
 
2724
 
 
2725
void CMakeAstTest::testQtWrapCppBadParse_data()
 
2726
{
 
2727
}
 
2728
 
 
2729
 
 
2730
 
 
2731
 
 
2732
 
 
2733
 
 
2734
 
 
2735
 
 
2736
 
 
2737
 
 
2738
void CMakeAstTest::testQtWrapUiGoodParse()
 
2739
{
 
2740
    TDD_TODO;
 
2741
    QFETCH( CMakeFunctionDesc, function );
 
2742
    CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_ui");
 
2743
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2744
    delete ast;
 
2745
}
 
2746
 
 
2747
void CMakeAstTest::testQtWrapUiGoodParse_data()
 
2748
{
 
2749
}
 
2750
 
 
2751
void CMakeAstTest::testQtWrapUiBadParse()
 
2752
{
 
2753
    TDD_TODO;
 
2754
    QFETCH( CMakeFunctionDesc, function );
 
2755
    CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_ui");
 
2756
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2757
    delete ast;
 
2758
}
 
2759
 
 
2760
void CMakeAstTest::testQtWrapUiBadParse_data()
 
2761
{
 
2762
}
 
2763
 
 
2764
 
 
2765
 
 
2766
 
 
2767
 
 
2768
 
 
2769
 
 
2770
 
 
2771
 
 
2772
 
 
2773
void CMakeAstTest::testRemoveGoodParse()
 
2774
{
 
2775
    TDD_TODO;
 
2776
    QFETCH( CMakeFunctionDesc, function );
 
2777
    CMakeAst* ast = AstFactory::self()->createAst("remove");
 
2778
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2779
    delete ast;
 
2780
}
 
2781
 
 
2782
void CMakeAstTest::testRemoveGoodParse_data()
 
2783
{
 
2784
}
 
2785
 
 
2786
void CMakeAstTest::testRemoveBadParse()
 
2787
{
 
2788
    TDD_TODO;
 
2789
    QFETCH( CMakeFunctionDesc, function );
 
2790
    CMakeAst* ast = AstFactory::self()->createAst("remove");
 
2791
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2792
    delete ast;
 
2793
}
 
2794
 
 
2795
void CMakeAstTest::testRemoveBadParse_data()
 
2796
{
 
2797
}
 
2798
 
 
2799
 
 
2800
 
 
2801
 
 
2802
 
 
2803
 
 
2804
 
 
2805
 
 
2806
 
 
2807
 
 
2808
void CMakeAstTest::testRemoveDefinitionsGoodParse()
 
2809
{
 
2810
    TDD_TODO;
 
2811
    QFETCH( CMakeFunctionDesc, function );
 
2812
    CMakeAst* ast = AstFactory::self()->createAst("remove_definitions");
 
2813
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2814
    delete ast;
 
2815
}
 
2816
 
 
2817
void CMakeAstTest::testRemoveDefinitionsGoodParse_data()
 
2818
{
 
2819
}
 
2820
 
 
2821
void CMakeAstTest::testRemoveDefinitionsBadParse()
 
2822
{
 
2823
    TDD_TODO;
 
2824
    QFETCH( CMakeFunctionDesc, function );
 
2825
    CMakeAst* ast = AstFactory::self()->createAst("remove_definitions");
 
2826
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2827
    delete ast;
 
2828
}
 
2829
 
 
2830
void CMakeAstTest::testRemoveDefinitionsBadParse_data()
 
2831
{
 
2832
}
 
2833
 
 
2834
 
 
2835
 
 
2836
 
 
2837
 
 
2838
 
 
2839
 
 
2840
 
 
2841
 
 
2842
 
 
2843
void CMakeAstTest::testReturnGoodParse()
 
2844
{
 
2845
    TDD_TODO;
 
2846
    QFETCH( CMakeFunctionDesc, function );
 
2847
    CMakeAst* ast = AstFactory::self()->createAst("return");
 
2848
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2849
    delete ast;
 
2850
}
 
2851
 
 
2852
void CMakeAstTest::testReturnGoodParse_data()
 
2853
{
 
2854
}
 
2855
 
 
2856
void CMakeAstTest::testReturnBadParse()
 
2857
{
 
2858
    TDD_TODO;
 
2859
    QFETCH( CMakeFunctionDesc, function );
 
2860
    CMakeAst* ast = AstFactory::self()->createAst("return");
 
2861
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2862
    delete ast;
 
2863
}
 
2864
 
 
2865
void CMakeAstTest::testReturnBadParse_data()
 
2866
{
 
2867
}
 
2868
 
 
2869
 
 
2870
 
 
2871
 
 
2872
 
 
2873
 
 
2874
 
 
2875
 
 
2876
 
 
2877
 
 
2878
void CMakeAstTest::testSeparateArgumentsGoodParse()
 
2879
{
 
2880
    TDD_TODO;
 
2881
    QFETCH( CMakeFunctionDesc, function );
 
2882
    CMakeAst* ast = AstFactory::self()->createAst("separate_arguments");
 
2883
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2884
    delete ast;
 
2885
}
 
2886
 
 
2887
void CMakeAstTest::testSeparateArgumentsGoodParse_data()
 
2888
{
 
2889
}
 
2890
 
 
2891
void CMakeAstTest::testSeparateArgumentsBadParse()
 
2892
{
 
2893
    TDD_TODO;
 
2894
    QFETCH( CMakeFunctionDesc, function );
 
2895
    CMakeAst* ast = AstFactory::self()->createAst("separate_arguments");
 
2896
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
2897
    delete ast;
 
2898
}
 
2899
 
 
2900
void CMakeAstTest::testSeparateArgumentsBadParse_data()
 
2901
{
 
2902
}
 
2903
 
 
2904
 
 
2905
 
 
2906
 
 
2907
 
 
2908
 
 
2909
 
 
2910
 
 
2911
 
 
2912
 
 
2913
void CMakeAstTest::testSetGoodParse()
 
2914
{
 
2915
    QFETCH( CMakeFunctionDesc, function );
 
2916
    CMakeAst* ast = AstFactory::self()->createAst("set");
 
2917
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2918
    delete ast;
 
2919
}
 
2920
 
 
2921
void CMakeAstTest::testSetGoodParse_data()
 
2922
{
 
2923
    CMakeFunctionDesc func1, func2, func3, func4, func5;
 
2924
    func1.name = "SET";
 
2925
    func2.name = func3.name = func4.name = func5.name = func1.name.toLower();
 
2926
 
 
2927
    QStringList argList1, argList2, argList3, argList4, argList5;
 
2928
    argList1 << "MYVAR";
 
2929
    argList2 << "MYVAR" << "value1";
 
2930
    argList3 << "MYVAR" << "CACHE" << "FILEPATH" << "docu";
 
2931
    argList4 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "FORCE";
 
2932
    argList5 << "MYVAR" << "value1" << "PARENT_SCOPE";
 
2933
 
 
2934
    func1.addArguments( argList1 );
 
2935
    func2.addArguments( argList2 );
 
2936
    func3.addArguments( argList3 );
 
2937
    func4.addArguments( argList4 );
 
2938
    func5.addArguments( argList5 );
 
2939
 
 
2940
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2941
    QTest::newRow( "good delete value" ) << func1;
 
2942
    QTest::newRow( "good set value" ) << func2;
 
2943
    QTest::newRow( "good set cache value" ) << func3;
 
2944
    QTest::newRow( "good set cache value forced" ) << func4;
 
2945
    QTest::newRow( "good set parent_scope" ) << func5;
 
2946
 
 
2947
}
 
2948
 
 
2949
void CMakeAstTest::testSetBadParse()
 
2950
{
 
2951
    QFETCH( CMakeFunctionDesc, function );
 
2952
    CMakeAst* ast = AstFactory::self()->createAst("set");
 
2953
    QCOMPARE( ast->parseFunctionInfo( function ), false );
 
2954
    delete ast;
 
2955
}
 
2956
 
 
2957
void CMakeAstTest::testSetBadParse_data()
 
2958
{
 
2959
    CMakeFunctionDesc func1, func2, func3, func4, func5, func6;
 
2960
    func1.name = "foobar_set";
 
2961
    func2.name = func3.name = func4.name = func5.name = func6.name = "set";
 
2962
 
 
2963
    QStringList argList1, argList2, argList3, argList4, argList5, argList6;
 
2964
    argList1 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "FORCE";
 
2965
    argList3 << "MYVAR" << "CACHE";
 
2966
    argList4 << "MYVAR" << "FORCE";
 
2967
    argList5 << "MYVAR" << "CACHE" << "STRING";
 
2968
    argList6 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "PARENT_SCOPE";
 
2969
    
 
2970
    func1.addArguments( argList1 );
 
2971
//     func2.addArguments( argList2 );
 
2972
    func3.addArguments( argList3 );
 
2973
    func4.addArguments( argList4 );
 
2974
    func5.addArguments( argList5 );
 
2975
    func6.addArguments( argList6 );
 
2976
    
 
2977
    qDebug() << func2.arguments.count();
 
2978
 
 
2979
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
2980
    QTest::newRow( "bad wrong name" ) << func1;
 
2981
    QTest::newRow( "bad no args" ) << func2;
 
2982
    QTest::newRow( "bad wrong cache use" ) << func3;
 
2983
    QTest::newRow( "bad wrong force use" ) << func4;
 
2984
    QTest::newRow( "bad wrong cache use 2" ) << func5;
 
2985
    QTest::newRow( "bad cache + parent_scope" ) << func6;
 
2986
 
 
2987
}
 
2988
 
 
2989
 
 
2990
 
 
2991
 
 
2992
 
 
2993
void CMakeAstTest::testSetPropertyGoodParse()
 
2994
{
 
2995
    TDD_TODO;
 
2996
    QFETCH( CMakeFunctionDesc, function );
 
2997
    CMakeAst* ast = AstFactory::self()->createAst("set_property");
 
2998
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
2999
    delete ast;
 
3000
}
 
3001
 
 
3002
void CMakeAstTest::testSetPropertyGoodParse_data()
 
3003
{
 
3004
}
 
3005
 
 
3006
void CMakeAstTest::testSetPropertyBadParse()
 
3007
{
 
3008
    TDD_TODO;
 
3009
    QFETCH( CMakeFunctionDesc, function );
 
3010
    CMakeAst* ast = AstFactory::self()->createAst("set_property");
 
3011
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3012
    delete ast;
 
3013
}
 
3014
 
 
3015
void CMakeAstTest::testSetPropertyBadParse_data()
 
3016
{
 
3017
}
 
3018
 
 
3019
 
 
3020
 
 
3021
 
 
3022
 
 
3023
 
 
3024
 
 
3025
void CMakeAstTest::testGetPropertyGoodParse()
 
3026
{
 
3027
    QFETCH( CMakeFunctionDesc, function );
 
3028
    CMakeAst* ast = AstFactory::self()->createAst("get_property");
 
3029
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3030
    delete ast;
 
3031
}
 
3032
 
 
3033
void CMakeAstTest::testGetPropertyGoodParse_data()
 
3034
{
 
3035
    CMakeFunctionDesc func1;
 
3036
    func1.name = "get_property";
 
3037
 
 
3038
    QStringList argList1;
 
3039
    argList1=QString("_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED").split(" ");
 
3040
 
 
3041
    func1.addArguments( argList1 );
 
3042
 
 
3043
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3044
    QTest::newRow( "good get" ) << func1;
 
3045
}
 
3046
 
 
3047
void CMakeAstTest::testGetPropertyBadParse()
 
3048
{
 
3049
    TDD_TODO;
 
3050
    QFETCH( CMakeFunctionDesc, function );
 
3051
    CMakeAst* ast = AstFactory::self()->createAst("get_property");
 
3052
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3053
    delete ast;
 
3054
}
 
3055
 
 
3056
void CMakeAstTest::testGetPropertyBadParse_data()
 
3057
{
 
3058
}
 
3059
 
 
3060
 
 
3061
 
 
3062
 
 
3063
 
 
3064
 
 
3065
 
 
3066
void CMakeAstTest::testSetDirectoryPropsGoodParse()
 
3067
{
 
3068
    TDD_TODO;
 
3069
    QFETCH( CMakeFunctionDesc, function );
 
3070
    CMakeAst* ast = AstFactory::self()->createAst("set_directory_properties");
 
3071
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3072
    delete ast;
 
3073
}
 
3074
 
 
3075
void CMakeAstTest::testSetDirectoryPropsGoodParse_data()
 
3076
{
 
3077
}
 
3078
 
 
3079
void CMakeAstTest::testSetDirectoryPropsBadParse()
 
3080
{
 
3081
    TDD_TODO;
 
3082
    QFETCH( CMakeFunctionDesc, function );
 
3083
    CMakeAst* ast = AstFactory::self()->createAst("set_directory_properties");
 
3084
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3085
    delete ast;
 
3086
}
 
3087
 
 
3088
void CMakeAstTest::testSetDirectoryPropsBadParse_data()
 
3089
{
 
3090
}
 
3091
 
 
3092
 
 
3093
 
 
3094
 
 
3095
 
 
3096
 
 
3097
 
 
3098
 
 
3099
 
 
3100
 
 
3101
void CMakeAstTest::testSetSourceFilesPropsGoodParse()
 
3102
{
 
3103
    TDD_TODO;
 
3104
    QFETCH( CMakeFunctionDesc, function );
 
3105
    CMakeAst* ast = AstFactory::self()->createAst("set_source_files_properties");
 
3106
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3107
    delete ast;
 
3108
}
 
3109
 
 
3110
void CMakeAstTest::testSetSourceFilesPropsGoodParse_data()
 
3111
{
 
3112
}
 
3113
 
 
3114
void CMakeAstTest::testSetSourceFilesPropsBadParse()
 
3115
{
 
3116
    TDD_TODO;
 
3117
    QFETCH( CMakeFunctionDesc, function );
 
3118
    CMakeAst* ast = AstFactory::self()->createAst("set_source_files_properties");
 
3119
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3120
    delete ast;
 
3121
}
 
3122
 
 
3123
void CMakeAstTest::testSetSourceFilesPropsBadParse_data()
 
3124
{
 
3125
}
 
3126
 
 
3127
 
 
3128
 
 
3129
 
 
3130
 
 
3131
 
 
3132
 
 
3133
 
 
3134
 
 
3135
 
 
3136
void CMakeAstTest::testSetTargetPropsGoodParse()
 
3137
{
 
3138
    TDD_TODO;
 
3139
    QFETCH( CMakeFunctionDesc, function );
 
3140
    CMakeAst* ast = AstFactory::self()->createAst("set_target_properties");
 
3141
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3142
    delete ast;
 
3143
}
 
3144
 
 
3145
void CMakeAstTest::testSetTargetPropsGoodParse_data()
 
3146
{
 
3147
}
 
3148
 
 
3149
void CMakeAstTest::testSetTargetPropsBadParse()
 
3150
{
 
3151
    TDD_TODO;
 
3152
    QFETCH( CMakeFunctionDesc, function );
 
3153
    CMakeAst* ast = AstFactory::self()->createAst("set_target_properties");
 
3154
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3155
    delete ast;
 
3156
}
 
3157
 
 
3158
void CMakeAstTest::testSetTargetPropsBadParse_data()
 
3159
{
 
3160
}
 
3161
 
 
3162
 
 
3163
 
 
3164
 
 
3165
 
 
3166
 
 
3167
 
 
3168
 
 
3169
 
 
3170
 
 
3171
void CMakeAstTest::testSetTestsPropsGoodParse()
 
3172
{
 
3173
    TDD_TODO;
 
3174
    QFETCH( CMakeFunctionDesc, function );
 
3175
    CMakeAst* ast = AstFactory::self()->createAst("set_tests_properties");
 
3176
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3177
    delete ast;
 
3178
}
 
3179
 
 
3180
void CMakeAstTest::testSetTestsPropsGoodParse_data()
 
3181
{
 
3182
}
 
3183
 
 
3184
void CMakeAstTest::testSetTestsPropsBadParse()
 
3185
{
 
3186
    TDD_TODO;
 
3187
    QFETCH( CMakeFunctionDesc, function );
 
3188
    CMakeAst* ast = AstFactory::self()->createAst("set_tests_properties");
 
3189
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3190
    delete ast;
 
3191
}
 
3192
 
 
3193
void CMakeAstTest::testSetTestsPropsBadParse_data()
 
3194
{
 
3195
}
 
3196
 
 
3197
 
 
3198
 
 
3199
 
 
3200
 
 
3201
 
 
3202
 
 
3203
 
 
3204
 
 
3205
 
 
3206
void CMakeAstTest::testSiteNameGoodParse()
 
3207
{
 
3208
    TDD_TODO;
 
3209
    QFETCH( CMakeFunctionDesc, function );
 
3210
    CMakeAst* ast = AstFactory::self()->createAst("site_name");
 
3211
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3212
    delete ast;
 
3213
}
 
3214
 
 
3215
void CMakeAstTest::testSiteNameGoodParse_data()
 
3216
{
 
3217
}
 
3218
 
 
3219
void CMakeAstTest::testSiteNameBadParse()
 
3220
{
 
3221
    TDD_TODO;
 
3222
    QFETCH( CMakeFunctionDesc, function );
 
3223
    CMakeAst* ast = AstFactory::self()->createAst("site_name");
 
3224
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3225
    delete ast;
 
3226
}
 
3227
 
 
3228
void CMakeAstTest::testSiteNameBadParse_data()
 
3229
{
 
3230
}
 
3231
 
 
3232
 
 
3233
 
 
3234
 
 
3235
 
 
3236
 
 
3237
 
 
3238
 
 
3239
 
 
3240
 
 
3241
void CMakeAstTest::testSourceGroupGoodParse()
 
3242
{
 
3243
    TDD_TODO;
 
3244
    QFETCH( CMakeFunctionDesc, function );
 
3245
    CMakeAst* ast = AstFactory::self()->createAst("source_group");
 
3246
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3247
    delete ast;
 
3248
}
 
3249
 
 
3250
void CMakeAstTest::testSourceGroupGoodParse_data()
 
3251
{
 
3252
}
 
3253
 
 
3254
void CMakeAstTest::testSourceGroupBadParse()
 
3255
{
 
3256
    TDD_TODO;
 
3257
    QFETCH( CMakeFunctionDesc, function );
 
3258
    CMakeAst* ast = AstFactory::self()->createAst("source_group");
 
3259
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3260
    delete ast;
 
3261
}
 
3262
 
 
3263
void CMakeAstTest::testSourceGroupBadParse_data()
 
3264
{
 
3265
}
 
3266
 
 
3267
 
 
3268
 
 
3269
 
 
3270
 
 
3271
 
 
3272
 
 
3273
 
 
3274
 
 
3275
 
 
3276
void CMakeAstTest::testStringGoodParse()
 
3277
{
 
3278
    QFETCH( CMakeFunctionDesc, function );
 
3279
    CMakeAst* ast = AstFactory::self()->createAst("string");
 
3280
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3281
    delete ast;
 
3282
}
 
3283
 
 
3284
void CMakeAstTest::testStringGoodParse_data()
 
3285
{
 
3286
    QStringList cases;
 
3287
    cases << "string STRIP string output";
 
3288
    cases << "string RANDOM output";
 
3289
    cases << "stRing RANDOM LENGTH 3 output";
 
3290
    cases << "string RANDOM ALPHABET abcd output";
 
3291
    cases << "string RANDOM output LENGTH 3 ALPHABET abcd";
 
3292
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3293
    
 
3294
    foreach(const QString& acase, cases)
 
3295
    {
 
3296
        QStringList splitted=acase.split(" ");
 
3297
        CMakeFunctionDesc func;
 
3298
        func.name = splitted.takeFirst();
 
3299
        func.addArguments(splitted);
 
3300
        QTest::newRow( qPrintable(acase) ) << func;
 
3301
    }
 
3302
}
 
3303
 
 
3304
void CMakeAstTest::testStringBadParse()
 
3305
{
 
3306
    TDD_TODO;
 
3307
    QFETCH( CMakeFunctionDesc, function );
 
3308
    CMakeAst* ast = AstFactory::self()->createAst("string");
 
3309
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3310
    delete ast;
 
3311
}
 
3312
 
 
3313
void CMakeAstTest::testStringBadParse_data()
 
3314
{
 
3315
}
 
3316
 
 
3317
 
 
3318
void CMakeAstTest::testSubdirDependsGoodParse()
 
3319
{
 
3320
    TDD_TODO;
 
3321
    QFETCH( CMakeFunctionDesc, function );
 
3322
    CMakeAst* ast = AstFactory::self()->createAst("subdir_depends");
 
3323
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3324
    delete ast;
 
3325
}
 
3326
 
 
3327
void CMakeAstTest::testSubdirDependsGoodParse_data()
 
3328
{
 
3329
}
 
3330
 
 
3331
void CMakeAstTest::testSubdirDependsBadParse()
 
3332
{
 
3333
    TDD_TODO;
 
3334
    QFETCH( CMakeFunctionDesc, function );
 
3335
    CMakeAst* ast = AstFactory::self()->createAst("subdir_depends");
 
3336
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3337
    delete ast;
 
3338
}
 
3339
 
 
3340
void CMakeAstTest::testSubdirDependsBadParse_data()
 
3341
{
 
3342
}
 
3343
 
 
3344
 
 
3345
 
 
3346
 
 
3347
 
 
3348
 
 
3349
 
 
3350
 
 
3351
 
 
3352
 
 
3353
void CMakeAstTest::testSubdirsGoodParse()
 
3354
{
 
3355
    TDD_TODO;
 
3356
    QFETCH( CMakeFunctionDesc, function );
 
3357
    CMakeAst* ast = AstFactory::self()->createAst("subdirs");
 
3358
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3359
    delete ast;
 
3360
}
 
3361
 
 
3362
void CMakeAstTest::testSubdirsGoodParse_data()
 
3363
{
 
3364
}
 
3365
 
 
3366
void CMakeAstTest::testSubdirsBadParse()
 
3367
{
 
3368
    TDD_TODO;
 
3369
    QFETCH( CMakeFunctionDesc, function );
 
3370
    CMakeAst* ast = AstFactory::self()->createAst("subdirs");
 
3371
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3372
    delete ast;
 
3373
}
 
3374
 
 
3375
void CMakeAstTest::testSubdirsBadParse_data()
 
3376
{
 
3377
}
 
3378
 
 
3379
 
 
3380
 
 
3381
 
 
3382
 
 
3383
 
 
3384
 
 
3385
 
 
3386
 
 
3387
 
 
3388
void CMakeAstTest::testTargetLinkLibrariesGoodParse()
 
3389
{
 
3390
    QFETCH( CMakeFunctionDesc, function );
 
3391
    CMakeAst* ast = AstFactory::self()->createAst("target_link_libraries");
 
3392
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3393
    delete ast;
 
3394
}
 
3395
 
 
3396
void CMakeAstTest::testTargetLinkLibrariesGoodParse_data()
 
3397
{
 
3398
    CMakeFunctionDesc func1, func2, func3;
 
3399
    func1.name = "TARGET_LINK_LIBRARIES";
 
3400
    func2.name = func3.name = func1.name.toLower();
 
3401
 
 
3402
    QStringList argList1, argList2, argList3;
 
3403
 
 
3404
    argList1 << "MYTARGET" << "SOME_VAR";
 
3405
    argList2 << "MYTARGET" << "debug" << "onlydebuglib";
 
3406
    argList3 << "MYTARGET" << "optimized" << "onlyoptimizedlib";
 
3407
 
 
3408
    func1.addArguments( argList1 );
 
3409
    func2.addArguments( argList2 );
 
3410
    func3.addArguments( argList3 );
 
3411
 
 
3412
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3413
    QTest::newRow( "whatever" ) << func1;
 
3414
    QTest::newRow( "whatever" ) << func2;
 
3415
    QTest::newRow( "whatever" ) << func3;
 
3416
 
 
3417
}
 
3418
 
 
3419
void CMakeAstTest::testTargetLinkLibrariesBadParse()
 
3420
{
 
3421
    QFETCH( CMakeFunctionDesc, function );
 
3422
    CMakeAst* ast = AstFactory::self()->createAst("target_link_libraries");
 
3423
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3424
    delete ast;
 
3425
}
 
3426
 
 
3427
void CMakeAstTest::testTargetLinkLibrariesBadParse_data()
 
3428
{
 
3429
    CMakeFunctionDesc func1, func2, func3, func4;
 
3430
    func1.name = "wrong_func_name";
 
3431
    func2.name = func3.name, func4.name = "target_link_libraries";
 
3432
 
 
3433
    QStringList argList1, argList2, argList3, argList4;
 
3434
 
 
3435
    argList1 << "MYTARGET" << "SOME_VAR";
 
3436
    argList2 << "MYTARGET";
 
3437
    argList3 << "MYTARGET" << "optimized";
 
3438
    argList4 << "MYTARGET" << "debug";
 
3439
 
 
3440
    func1.addArguments( argList1 );
 
3441
    func2.addArguments( argList2 );
 
3442
    func3.addArguments( argList3 );
 
3443
    func4.addArguments( argList4 );
 
3444
 
 
3445
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3446
    QTest::newRow( "whatever" ) << func1;
 
3447
    QTest::newRow( "whatever" ) << func2;
 
3448
    QTest::newRow( "whatever" ) << func3;
 
3449
    QTest::newRow( "whatever" ) << func4;
 
3450
 
 
3451
}
 
3452
 
 
3453
 
 
3454
 
 
3455
 
 
3456
void CMakeAstTest::testTryCompileGoodParse()
 
3457
{
 
3458
    QFETCH( CMakeFunctionDesc, function );
 
3459
    CMakeAst* ast = AstFactory::self()->createAst("try_compile");
 
3460
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3461
    delete ast;
 
3462
}
 
3463
 
 
3464
void CMakeAstTest::testTryCompileGoodParse_data()
 
3465
{
 
3466
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3467
 
 
3468
    CMakeFunctionDesc l;
 
3469
    l.name = "try_compile";
 
3470
    l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir" << "myProjectName");
 
3471
    QTest::newRow("cmake way") << l;
 
3472
 
 
3473
    l.arguments.clear();
 
3474
    l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir");
 
3475
    QTest::newRow("compile way") << l;
 
3476
 
 
3477
    l.arguments.clear();
 
3478
    l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir" << "COMPILE_DEFINITIONS" << "-D LOL");
 
3479
    QTest::newRow("more complex compile") << l;
 
3480
}
 
3481
 
 
3482
void CMakeAstTest::testTryCompileBadParse()
 
3483
{
 
3484
    QFETCH( CMakeFunctionDesc, function );
 
3485
    CMakeAst* ast = AstFactory::self()->createAst("try_compile");
 
3486
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3487
    delete ast;
 
3488
}
 
3489
 
 
3490
void CMakeAstTest::testTryCompileBadParse_data()
 
3491
{
 
3492
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3493
 
 
3494
    CMakeFunctionDesc l;
 
3495
    l.name = "try_compile";
 
3496
    QTest::newRow("no parameters") << l;
 
3497
 
 
3498
}
 
3499
 
 
3500
 
 
3501
 
 
3502
 
 
3503
 
 
3504
 
 
3505
 
 
3506
 
 
3507
 
 
3508
 
 
3509
void CMakeAstTest::testTryRunGoodParse()
 
3510
{
 
3511
    TDD_TODO;
 
3512
    QFETCH( CMakeFunctionDesc, function );
 
3513
    CMakeAst* ast = AstFactory::self()->createAst("try_run");
 
3514
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3515
    delete ast;
 
3516
}
 
3517
 
 
3518
void CMakeAstTest::testTryRunGoodParse_data()
 
3519
{
 
3520
}
 
3521
 
 
3522
void CMakeAstTest::testTryRunBadParse()
 
3523
{
 
3524
    TDD_TODO;
 
3525
    QFETCH( CMakeFunctionDesc, function );
 
3526
    CMakeAst* ast = AstFactory::self()->createAst("try_run");
 
3527
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3528
    delete ast;
 
3529
}
 
3530
 
 
3531
void CMakeAstTest::testTryRunBadParse_data()
 
3532
{
 
3533
}
 
3534
 
 
3535
 
 
3536
 
 
3537
 
 
3538
 
 
3539
 
 
3540
 
 
3541
 
 
3542
 
 
3543
 
 
3544
void CMakeAstTest::testUseMangledMesaGoodParse()
 
3545
{
 
3546
    TDD_TODO;
 
3547
    QFETCH( CMakeFunctionDesc, function );
 
3548
    CMakeAst* ast = AstFactory::self()->createAst("use_mangled_mesa");
 
3549
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3550
    delete ast;
 
3551
}
 
3552
 
 
3553
void CMakeAstTest::testUseMangledMesaGoodParse_data()
 
3554
{
 
3555
}
 
3556
 
 
3557
void CMakeAstTest::testUseMangledMesaBadParse()
 
3558
{
 
3559
    TDD_TODO;
 
3560
    QFETCH( CMakeFunctionDesc, function );
 
3561
    CMakeAst* ast = AstFactory::self()->createAst("use_mangled_mesa");
 
3562
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3563
    delete ast;
 
3564
}
 
3565
 
 
3566
void CMakeAstTest::testUseMangledMesaBadParse_data()
 
3567
{
 
3568
}
 
3569
 
 
3570
 
 
3571
 
 
3572
 
 
3573
 
 
3574
 
 
3575
 
 
3576
 
 
3577
 
 
3578
 
 
3579
void CMakeAstTest::testUtilitySourceGoodParse()
 
3580
{
 
3581
    TDD_TODO;
 
3582
    QFETCH( CMakeFunctionDesc, function );
 
3583
    CMakeAst* ast = AstFactory::self()->createAst("utility_source");
 
3584
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3585
    delete ast;
 
3586
}
 
3587
 
 
3588
void CMakeAstTest::testUtilitySourceGoodParse_data()
 
3589
{
 
3590
}
 
3591
 
 
3592
void CMakeAstTest::testUtilitySourceBadParse()
 
3593
{
 
3594
    TDD_TODO;
 
3595
    QFETCH( CMakeFunctionDesc, function );
 
3596
    CMakeAst* ast = AstFactory::self()->createAst("utility_source");
 
3597
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3598
    delete ast;
 
3599
}
 
3600
 
 
3601
void CMakeAstTest::testUtilitySourceBadParse_data()
 
3602
{
 
3603
}
 
3604
 
 
3605
 
 
3606
 
 
3607
 
 
3608
 
 
3609
 
 
3610
 
 
3611
 
 
3612
 
 
3613
 
 
3614
void CMakeAstTest::testVariableRequiresGoodParse()
 
3615
{
 
3616
    TDD_TODO;
 
3617
    QFETCH( CMakeFunctionDesc, function );
 
3618
    CMakeAst* ast = AstFactory::self()->createAst("variable_requires");
 
3619
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3620
    delete ast;
 
3621
}
 
3622
 
 
3623
void CMakeAstTest::testVariableRequiresGoodParse_data()
 
3624
{
 
3625
}
 
3626
 
 
3627
void CMakeAstTest::testVariableRequiresBadParse()
 
3628
{
 
3629
    TDD_TODO;
 
3630
    QFETCH( CMakeFunctionDesc, function );
 
3631
    CMakeAst* ast = AstFactory::self()->createAst("variable_requires");
 
3632
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3633
    delete ast;
 
3634
}
 
3635
 
 
3636
void CMakeAstTest::testVariableRequiresBadParse_data()
 
3637
{
 
3638
}
 
3639
 
 
3640
 
 
3641
 
 
3642
 
 
3643
 
 
3644
 
 
3645
 
 
3646
 
 
3647
 
 
3648
 
 
3649
void CMakeAstTest::testVtkMakeInstantiatorGoodParse()
 
3650
{
 
3651
    TDD_TODO;
 
3652
    QFETCH( CMakeFunctionDesc, function );
 
3653
    CMakeAst* ast = AstFactory::self()->createAst("vtk_make_instantiator");
 
3654
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3655
    delete ast;
 
3656
}
 
3657
 
 
3658
void CMakeAstTest::testVtkMakeInstantiatorGoodParse_data()
 
3659
{
 
3660
}
 
3661
 
 
3662
void CMakeAstTest::testVtkMakeInstantiatorBadParse()
 
3663
{
 
3664
    TDD_TODO;
 
3665
    QFETCH( CMakeFunctionDesc, function );
 
3666
    CMakeAst* ast = AstFactory::self()->createAst("vtk_make_instantiator");
 
3667
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3668
    delete ast;
 
3669
}
 
3670
 
 
3671
void CMakeAstTest::testVtkMakeInstantiatorBadParse_data()
 
3672
{
 
3673
}
 
3674
 
 
3675
 
 
3676
 
 
3677
 
 
3678
 
 
3679
 
 
3680
 
 
3681
 
 
3682
 
 
3683
 
 
3684
void CMakeAstTest::testVtkWrapJavaGoodParse()
 
3685
{
 
3686
    TDD_TOIMPL;
 
3687
    QFETCH( CMakeFunctionDesc, function );
 
3688
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_java");
 
3689
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3690
    delete ast;
 
3691
}
 
3692
 
 
3693
void CMakeAstTest::testVtkWrapJavaGoodParse_data()
 
3694
{
 
3695
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3696
 
 
3697
    const int NUM_TESTDATA = 2;
 
3698
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3699
    QStringList args[NUM_TESTDATA];
 
3700
 
 
3701
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3702
        funcs[i].name = "VTK_WRAP_JAVA";
 
3703
 
 
3704
    //test lowercase too
 
3705
    funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
 
3706
 
 
3707
    args[0] << "myLibrary" << "MySourceList" << "source1";
 
3708
    args[1] << "myLibrary" << "MySourceList" << "source1" << "source2";
 
3709
 
 
3710
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3711
 
 
3712
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3713
    {
 
3714
        funcs[i].addArguments( args[i] );
 
3715
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3716
    }
 
3717
}
 
3718
 
 
3719
void CMakeAstTest::testVtkWrapJavaBadParse()
 
3720
{
 
3721
    TDD_TOIMPL;
 
3722
    QFETCH( CMakeFunctionDesc, function );
 
3723
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_java");
 
3724
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3725
    delete ast;
 
3726
}
 
3727
 
 
3728
void CMakeAstTest::testVtkWrapJavaBadParse_data()
 
3729
{
 
3730
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3731
 
 
3732
    const int NUM_TESTDATA = 3;
 
3733
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3734
    QStringList args[NUM_TESTDATA];
 
3735
 
 
3736
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3737
        funcs[i].name = "VTK_WRAP_JAVA";
 
3738
 
 
3739
    funcs[NUM_TESTDATA - 1].name = "wrong_name";
 
3740
 
 
3741
    args[0] << "myLibrary"; //no source list and no sources
 
3742
    args[1] << "myLibrary" << "MySourceList"; //source list but no sources
 
3743
    args[NUM_TESTDATA - 1] << "myLibrary" << "MySourceList" << "source1";
 
3744
 
 
3745
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3746
 
 
3747
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3748
    {
 
3749
        funcs[i].addArguments( args[i] );
 
3750
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3751
    }
 
3752
}
 
3753
 
 
3754
 
 
3755
 
 
3756
 
 
3757
 
 
3758
 
 
3759
 
 
3760
 
 
3761
 
 
3762
 
 
3763
void CMakeAstTest::testVtkWrapPythonGoodParse()
 
3764
{
 
3765
    TDD_TOIMPL;
 
3766
    QFETCH( CMakeFunctionDesc, function );
 
3767
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_python");
 
3768
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3769
    delete ast;
 
3770
}
 
3771
 
 
3772
void CMakeAstTest::testVtkWrapPythonGoodParse_data()
 
3773
{
 
3774
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3775
 
 
3776
    const int NUM_TESTDATA = 2;
 
3777
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3778
    QStringList args[NUM_TESTDATA];
 
3779
 
 
3780
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3781
        funcs[i].name = "VTK_WRAP_PYTHON";
 
3782
 
 
3783
    //test lowercase too
 
3784
    funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
 
3785
 
 
3786
    args[0] << "myLibrary" << "MySourceList" << "source1";
 
3787
    args[1] << "myLibrary" << "MySourceList" << "source1" << "source2";
 
3788
 
 
3789
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3790
 
 
3791
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3792
    {
 
3793
        funcs[i].addArguments( args[i] );
 
3794
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3795
    }
 
3796
}
 
3797
 
 
3798
void CMakeAstTest::testVtkWrapPythonBadParse()
 
3799
{
 
3800
    TDD_TOIMPL;
 
3801
    QFETCH( CMakeFunctionDesc, function );
 
3802
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_python");
 
3803
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3804
    delete ast;
 
3805
}
 
3806
 
 
3807
void CMakeAstTest::testVtkWrapPythonBadParse_data()
 
3808
{
 
3809
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3810
 
 
3811
    const int NUM_TESTDATA = 3;
 
3812
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3813
    QStringList args[NUM_TESTDATA];
 
3814
 
 
3815
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3816
        funcs[i].name = "VTK_WRAP_PYTHON";
 
3817
 
 
3818
    funcs[NUM_TESTDATA - 1].name = "wrong_name";
 
3819
 
 
3820
    args[0] << "myLibrary"; //no source list and no sources
 
3821
    args[1] << "myLibrary" << "MySourceList"; //source list but no sources
 
3822
    args[NUM_TESTDATA - 1] << "myLibrary" << "MySourceList" << "source1";
 
3823
 
 
3824
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3825
 
 
3826
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3827
    {
 
3828
        funcs[i].addArguments( args[i] );
 
3829
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3830
    }
 
3831
}
 
3832
 
 
3833
 
 
3834
 
 
3835
 
 
3836
 
 
3837
 
 
3838
 
 
3839
 
 
3840
 
 
3841
 
 
3842
void CMakeAstTest::testVtkWrapTclGoodParse()
 
3843
{
 
3844
    TDD_TOIMPL;
 
3845
    QFETCH( CMakeFunctionDesc, function );
 
3846
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_tcl");
 
3847
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3848
    delete ast;
 
3849
}
 
3850
 
 
3851
void CMakeAstTest::testVtkWrapTclGoodParse_data()
 
3852
{
 
3853
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3854
 
 
3855
    const int NUM_TESTDATA = 6;
 
3856
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3857
    QStringList args[NUM_TESTDATA];
 
3858
 
 
3859
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3860
        funcs[i].name = "VTK_WRAP_TCL";
 
3861
 
 
3862
    //test lowercase too
 
3863
    funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
 
3864
 
 
3865
    args[0] << "myLibrary" << "MySourceList" << "source1.tcl";
 
3866
    
 
3867
    //SOURCES is optional
 
3868
    args[1] << "myLibrary" << "SOURCES" << "MySourceList" << "source1.tcl";
 
3869
    
 
3870
    //multiple sources
 
3871
    args[2] << "myLibrary" << "SOURCES" << "MySourceList" << "source1.tcl"
 
3872
            << "source2.tcl";
 
3873
 
 
3874
    //commands are optional
 
3875
    args[3] << "myLibrary" << "MySourceList" << "source1.tcl"
 
3876
            << "COMMANDS" << "com1";
 
3877
 
 
3878
    //multiple commands
 
3879
    args[4] << "myLibrary" << "MySourceList" << "source1.tcl"
 
3880
            << "COMMANDS" << "com1" << "com2";
 
3881
            
 
3882
    //line from the cmake example
 
3883
    args[NUM_TESTDATA - 1] << "myLibrary" << "SOURCES"
 
3884
            << "MySourceList" << "class1" << "class2"
 
3885
            << "COMMANDS" << "first_command" << "second_command";
 
3886
    
 
3887
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3888
 
 
3889
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3890
    {
 
3891
        funcs[i].addArguments( args[i] );
 
3892
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3893
    }
 
3894
}
 
3895
 
 
3896
void CMakeAstTest::testVtkWrapTclBadParse()
 
3897
{
 
3898
    TDD_TOIMPL;
 
3899
    QFETCH( CMakeFunctionDesc, function );
 
3900
    CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_tcl");
 
3901
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3902
    delete ast;
 
3903
}
 
3904
 
 
3905
void CMakeAstTest::testVtkWrapTclBadParse_data()
 
3906
{
 
3907
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3908
 
 
3909
    const int NUM_TESTDATA = 5;
 
3910
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3911
    QStringList args[NUM_TESTDATA];
 
3912
 
 
3913
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3914
        funcs[i].name = "VTK_WRAP_TCL";
 
3915
 
 
3916
    funcs[NUM_TESTDATA - 1].name = "wrong_name";
 
3917
 
 
3918
    args[0] << "myLibrary"; //no source list and no sources
 
3919
    args[1] << "myLibrary" << "MySourceList"; //source list but no sources
 
3920
    args[2] << "myLibrary" << "SOURCES" << "MySourceList"; //source list but no sources
 
3921
    args[3] << "myLibrary" << "SOURCES" << "MySourceList" << "foo.tcl";
 
3922
    args[NUM_TESTDATA - 1] << "myLibrary" << "SOURCES"
 
3923
            << "MySourceList" << "class1" << "class2"
 
3924
            << "COMMANDS" << "first_command";
 
3925
    
 
3926
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3927
 
 
3928
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
3929
    {
 
3930
        funcs[i].addArguments( args[i] );
 
3931
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
3932
    }
 
3933
}
 
3934
 
 
3935
 
 
3936
 
 
3937
 
 
3938
 
 
3939
 
 
3940
 
 
3941
 
 
3942
 
 
3943
 
 
3944
void CMakeAstTest::testWhileGoodParse()
 
3945
{
 
3946
    TDD_TODO;
 
3947
    QFETCH( CMakeFunctionDesc, function );
 
3948
    CMakeAst* ast = AstFactory::self()->createAst("while");
 
3949
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3950
    delete ast;
 
3951
}
 
3952
 
 
3953
void CMakeAstTest::testWhileGoodParse_data()
 
3954
{
 
3955
}
 
3956
 
 
3957
void CMakeAstTest::testWhileBadParse()
 
3958
{
 
3959
    TDD_TODO;
 
3960
    QFETCH( CMakeFunctionDesc, function );
 
3961
    CMakeAst* ast = AstFactory::self()->createAst("while");
 
3962
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
3963
    delete ast;
 
3964
}
 
3965
 
 
3966
void CMakeAstTest::testWhileBadParse_data()
 
3967
{
 
3968
}
 
3969
 
 
3970
 
 
3971
void CMakeAstTest::testWriteFileGoodParse()
 
3972
{
 
3973
    QFETCH( CMakeFunctionDesc, function );
 
3974
    CMakeAst* ast = AstFactory::self()->createAst("write_file");
 
3975
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
3976
    delete ast;
 
3977
}
 
3978
 
 
3979
void CMakeAstTest::testWriteFileGoodParse_data()
 
3980
{
 
3981
    QTest::addColumn<CMakeFunctionDesc>("function");
 
3982
 
 
3983
    const int NUM_TESTDATA = 2;
 
3984
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
3985
    QStringList args[NUM_TESTDATA];
 
3986
 
 
3987
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
3988
    {
 
3989
        funcs[i].name = "WRITE_FILE";
 
3990
        if ( i % 2 == 0 )
 
3991
            funcs[i].name.toLower();
 
3992
    }
 
3993
    
 
3994
    args[0] << "myfile.txt" << "\"this is my message\"";
 
3995
    args[1] << "myfile.txt" << "\"this is also my message\"" << "APPEND";
 
3996
    
 
3997
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
3998
 
 
3999
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
4000
    {
 
4001
        funcs[i].addArguments( args[i] );
 
4002
        QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
 
4003
    }
 
4004
}
 
4005
 
 
4006
void CMakeAstTest::testWriteFileBadParse()
 
4007
{
 
4008
    QFETCH( CMakeFunctionDesc, function );
 
4009
    CMakeAst* ast = AstFactory::self()->createAst("write_file");
 
4010
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
4011
    delete ast;
 
4012
}
 
4013
 
 
4014
void CMakeAstTest::testWriteFileBadParse_data()
 
4015
{
 
4016
    QTest::addColumn<CMakeFunctionDesc>("function");
 
4017
 
 
4018
    const int NUM_TESTDATA = 3;
 
4019
    CMakeFunctionDesc funcs[NUM_TESTDATA];
 
4020
    QStringList args[NUM_TESTDATA];
 
4021
 
 
4022
    for ( int i = 0; i < NUM_TESTDATA; i++ )
 
4023
        funcs[i].name = "WRITE_FILE";
 
4024
 
 
4025
    funcs[NUM_TESTDATA - 1].name = "wrong_name";
 
4026
    
 
4027
    args[0] << "myfile.txt";
 
4028
//     args[1] << "myfile.txt" << "APPEND"; //append but no message. Should not crash, "append" is the message.
 
4029
    args[NUM_TESTDATA - 1] << "myfile.txt" << "\"this is also my message\"" << "APPEND";
 
4030
    
 
4031
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
4032
 
 
4033
    for ( int i = 0; i < NUM_TESTDATA; i++)
 
4034
    {
 
4035
        funcs[i].addArguments( args[i] );
 
4036
        QTest::newRow( qPrintable(QString("%1. %2").arg(i).arg(args[i].join(" "))) ) << funcs[i];
 
4037
    }
 
4038
}
 
4039
 
 
4040