Test module type support
[reactos.git] / reactos / tools / rbuild / tests / sourcefiletest.cpp
1 #include "test.h"
2
3 using std::string;
4
5 bool
6 SourceFileTest::IsParentOf ( const SourceFile* parent,
7 const SourceFile* child )
8 {
9 size_t i;
10 for ( i = 0; i < child->parents.size (); i++ )
11 {
12 if ( child->parents[i] != NULL )
13 {
14 if ( child->parents[i] == parent )
15 {
16 return true;
17 }
18 }
19 }
20 for ( i = 0; i < child->parents.size (); i++ )
21 {
22 if ( child->parents[i] != NULL )
23 {
24 if ( IsParentOf ( parent,
25 child->parents[i] ) )
26 {
27 return true;
28 }
29 }
30 }
31 return false;
32 }
33
34 void
35 SourceFileTest::IncludeTest ()
36 {
37 const Project project ( RBUILD_BASE "tests" SSEP "data" SSEP "automaticdependency_include.xml" );
38 AutomaticDependency automaticDependency ( project );
39 automaticDependency.Process ();
40 ARE_EQUAL( 4, automaticDependency.sourcefile_map.size () );
41 const SourceFile* include = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" );
42 IS_NOT_NULL( include );
43 const SourceFile* includenext = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" );
44 IS_NOT_NULL( includenext );
45 }
46
47 void
48 SourceFileTest::FullParseTest ()
49 {
50 const Project project ( RBUILD_BASE "tests" SSEP "data" SSEP "automaticdependency.xml" );
51 AutomaticDependency automaticDependency ( project );
52 automaticDependency.Process ();
53 ARE_EQUAL( 5, automaticDependency.sourcefile_map.size () );
54 const SourceFile* header1 = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" );
55 IS_NOT_NULL( header1 );
56 const SourceFile* recurse = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_recurse.h" );
57 IS_NOT_NULL( recurse );
58 IS_TRUE( IsParentOf ( header1,
59 recurse ) );
60 IS_FALSE( IsParentOf ( recurse,
61 header1 ) );
62
63 }
64
65 void
66 SourceFileTest::Run ()
67 {
68 IncludeTest ();
69 FullParseTest ();
70 }