2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 SourceFileTest::IsParentOf ( const SourceFile
* parent
,
24 const SourceFile
* child
)
27 for ( i
= 0; i
< child
->parents
.size (); i
++ )
29 if ( child
->parents
[i
] != NULL
)
31 if ( child
->parents
[i
] == parent
)
37 for ( i
= 0; i
< child
->parents
.size (); i
++ )
39 if ( child
->parents
[i
] != NULL
)
41 if ( IsParentOf ( parent
,
52 SourceFileTest::IncludeTest ()
54 const Project
project ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"automaticdependency_include.xml" );
55 AutomaticDependency
automaticDependency ( project
);
56 automaticDependency
.ParseFiles ();
57 ARE_EQUAL( 4, automaticDependency
.sourcefile_map
.size () );
58 const SourceFile
* include
= automaticDependency
.RetrieveFromCache ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"sourcefile_include.h" );
59 IS_NOT_NULL( include
);
60 const SourceFile
* includenext
= automaticDependency
.RetrieveFromCache ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"sourcefile1" SSEP
"sourcefile_includenext.h" );
61 IS_NOT_NULL( includenext
);
65 SourceFileTest::FullParseTest ()
67 const Project
project ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"automaticdependency.xml" );
68 AutomaticDependency
automaticDependency ( project
);
69 automaticDependency
.ParseFiles ();
70 ARE_EQUAL( 5, automaticDependency
.sourcefile_map
.size () );
71 const SourceFile
* header1
= automaticDependency
.RetrieveFromCache ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"sourcefile1_header1.h" );
72 IS_NOT_NULL( header1
);
73 const SourceFile
* recurse
= automaticDependency
.RetrieveFromCache ( RBUILD_BASE
"tests" SSEP
"data" SSEP
"sourcefile1_recurse.h" );
74 IS_NOT_NULL( recurse
);
75 IS_TRUE( IsParentOf ( header1
,
77 IS_FALSE( IsParentOf ( recurse
,
83 SourceFileTest::Run ()