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

« back to all changes in this revision

Viewing changes to projectmanagers/cmake/tests/cmakecustomtargetasttest.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
/* KDevelop CMake Support
 
2
 *
 
3
 * Copyright 2006 Matt Rogers <mattr@kde.org>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
 * 02110-1301, USA.
 
19
 */
 
20
 
 
21
#include "cmakecustomtargetasttest.h"
 
22
#include "cmakeast.h"
 
23
#include "cmakelistsparser.h"
 
24
 
 
25
QTEST_MAIN( CustomTargetAstTests )
 
26
 
 
27
void CustomTargetAstTests::testGoodParse()
 
28
{
 
29
    QFETCH( CMakeFunctionDesc, function );
 
30
    CustomTargetAst* ast = new CustomTargetAst();
 
31
    QVERIFY( ast->parseFunctionInfo( function ) == true );
 
32
    delete ast;
 
33
}
 
34
 
 
35
void CustomTargetAstTests::testGoodParse_data()
 
36
{
 
37
    CMakeFunctionDesc func1;
 
38
    func1.name = "add_custom_target";
 
39
    QStringList argList1;
 
40
    argList1 << "MyName" << "ALL" << "foobar --test" << "COMMAND"
 
41
             << "barbaz --foo" << "DEPENDS" << "dep1" << "dep2" << "dep3"
 
42
             << "WORKING_DIRECTORY" << "/path/to/my/dir" << "COMMENT"
 
43
             << "this is my comment" << "VERBATIM";
 
44
    func1.addArguments( argList1 );
 
45
 
 
46
    CMakeFunctionDesc func2;
 
47
    func2.name = "ADD_CUSTOM_TARGET";
 
48
    QStringList argList2;
 
49
    argList2 << "MyName" << "my_command --test-param 1";
 
50
    func2.addArguments( argList2 );
 
51
 
 
52
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
53
    QTest::newRow( "all optional" ) << func1;
 
54
    QTest::newRow( "no optional" ) << func2;
 
55
}
 
56
 
 
57
void CustomTargetAstTests::testBadParse()
 
58
{
 
59
    QFETCH( CMakeFunctionDesc, function );
 
60
    CustomTargetAst* ast = new CustomTargetAst();
 
61
    QVERIFY( ast->parseFunctionInfo( function ) == false );
 
62
    delete ast;
 
63
}
 
64
 
 
65
void CustomTargetAstTests::testBadParse_data()
 
66
{
 
67
    CMakeFunctionDesc func1;
 
68
    func1.name = "add_custom_target";
 
69
    QStringList argList1;
 
70
    argList1 << "IAm#1" << "ALL" << "foobar --test" << "COMMAND"
 
71
             << "barbaz --foo" << "DEPENDS" << "dep1" << "dep2" << "dep3"
 
72
             << "WORKING_DIRECTORY" << "/path/to/my/dir" << "COMMENT"
 
73
             << "this is my comment" << "VERBATIM";
 
74
    func1.addArguments( argList1 );
 
75
 
 
76
    CMakeFunctionDesc func2;
 
77
    func2.name = "ADD_CUSTOM_TARGET";
 
78
    QStringList argList2;
 
79
    argList2 << "ALL" << "my_command --test-param 1";
 
80
    func2.addArguments( argList2 );
 
81
 
 
82
    CMakeFunctionDesc func3;
 
83
    func3.name = "add_custom_target";
 
84
 
 
85
    QTest::addColumn<CMakeFunctionDesc>( "function" );
 
86
    QTest::newRow( "bad 1" ) << func1;
 
87
    QTest::newRow( "bad 2" ) << func2;
 
88
    QTest::newRow( "bad 3" ) << func3;
 
89
}
 
90
 
 
91
#include "cmakecustomtargetasttest.moc"