Add project and module tests.
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/makefile
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/
Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/projecttest.cpp

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/makefile
--- branches/xmlbuildsystem/reactos/tools/rbuild/makefile	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/makefile	2005-01-04 21:29:09 UTC (rev 12801)
@@ -13,7 +13,9 @@
 
 OBJECTS = $(BASE_OBJECTS) rbuild.o
 
-TESTS = tests/moduletest.o
+TESTS = \
+	tests/moduletest.o \
+	tests/projecttest.o
 
 TEST_OBJECTS = $(BASE_OBJECTS) $(TESTS) tests/alltests.o
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-01-04 21:29:09 UTC (rev 12801)
@@ -58,7 +58,8 @@
 	}
 	catch (Exception& ex)
 	{
-		printf ( ex.Message.c_str() );
+		printf ( "%s\n",
+		         ex.Message.c_str() );
 		return 1;
 	}
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/test.h	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/test.h	2005-01-04 21:29:09 UTC (rev 12801)
@@ -14,18 +14,26 @@
 	void Assert(const char *message, ...);
 	void IsTrue(bool condition,
 	            const char* file,
-	            int line );
+	            int line);
 	void IsFalse(bool condition,
 	             const char* file,
-	             int line );
+	             int line);
 	void AreEqual(int expected,
 	              int actual,
 	              const char* file,
-	              int line );
+	              int line);
+	void AreEqual(string expected,
+	              string actual,
+	              const char* file,
+	              int line);
+	void AreEqual(const char* expected,
+	              string actual,
+	              const char* file,
+	              int line);
 	void AreNotEqual(int expected,
 	                 int actual,
 	                 const char* file,
-	                 int line );
+	                 int line);
 private:
 	void Fail();
 };
@@ -35,6 +43,13 @@
 #define ARE_EQUAL(expected,actual) AreEqual(expected,actual,__FILE__,__LINE__)
 #define ARE_NOT_EQUAL(expected,actual) AreNotEqual(expected,actual,__FILE__,__LINE__)
 
+class ProjectTest : public BaseTest
+{
+public:
+	void Run();
+};
+
+
 class ModuleTest : public BaseTest
 {
 public:

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp	2005-01-04 21:29:09 UTC (rev 12801)
@@ -4,7 +4,7 @@
 
 BaseTest::BaseTest()
 {
-	Failed = true;
+	Failed = false;
 }
 
 BaseTest::~BaseTest()
@@ -61,6 +61,32 @@
 	}
 }
 
+void BaseTest::AreEqual(string expected,
+                        string actual,
+                        const char* file,
+                        int line)
+{
+	if (actual != expected)
+	{
+		Assert("Expected '%s' was '%s' at %s:%d\n",
+		       expected.c_str(),
+		       actual.c_str(),
+		       file,
+		       line);
+	}
+}
+
+void BaseTest::AreEqual(const char* expected,
+                        string actual,
+                        const char* file,
+                        int line)
+{
+	AreEqual(string(expected),
+             actual,
+             file,
+             line);
+}
+
 void BaseTest::AreNotEqual(int expected,
                            int actual,
                            const char* file,
@@ -103,10 +129,19 @@
 		GetTests(tests);
 		for (size_t i = 0; i < tests.size(); i++)
 		{
-			BaseTest& test = *tests[i];
-			test.Run();
-			if (test.Failed)
+			try
+			{
+				BaseTest& test = *tests[i];
+				test.Run();
+				if (test.Failed)
+					numberOfFailedTests++;
+			}
+			catch (Exception& ex)
+			{
+				printf("%s\n",
+				       ex.Message.c_str());
 				numberOfFailedTests++;
+			}
 		}
 		
 		if (numberOfFailedTests > 0)
@@ -119,6 +154,7 @@
 private:
 	void GetTests ( BaseTestList& tests )
 	{
+		tests.push_back(new ProjectTest());
 		tests.push_back(new ModuleTest());
 	}
 };

Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml	2005-01-04 21:29:09 UTC (rev 12801)
@@ -0,0 +1,14 @@
+<project name="Project">
+	<directory name="dir1">
+		<module name="module1" type="buildtool">
+			<file>file1.c</file>
+			<file>file2.c</file>
+		</module>
+	</directory>
+	<directory name="dir2">
+		<module name="module2" type="buildtool">
+			<file>file3.c</file>
+			<file>file4.c</file>
+		</module>
+	</directory>
+</project>

Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/project.xml	2005-01-04 21:29:09 UTC (rev 12801)
@@ -0,0 +1,10 @@
+<project name="Project">
+	<directory name="dir1">
+		<module name="module1" type="buildtool">
+		</module>
+	</directory>
+	<directory name="dir2">
+		<module name="module2" type="buildtool">
+		</module>
+	</directory>
+</project>

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp	2005-01-04 21:29:09 UTC (rev 12801)
@@ -2,5 +2,17 @@
 
 void ModuleTest::Run()
 {
-	IS_TRUE(false);
+	string projectFilename ( "tests/data/module.xml" );
+	Project* project = new Project( projectFilename );
+	ARE_EQUAL(2, project->modules.size());
+
+	Module& module1 = *project->modules[0];
+	ARE_EQUAL(2, module1.files.size());
+	ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
+	ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
+	
+	Module& module2 = *project->modules[1];
+	ARE_EQUAL(2, module2.files.size());
+	ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
+	ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
 }

Added: branches/xmlbuildsystem/reactos/tools/rbuild/tests/projecttest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/projecttest.cpp	2005-01-04 21:25:20 UTC (rev 12800)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/projecttest.cpp	2005-01-04 21:29:09 UTC (rev 12801)
@@ -0,0 +1,8 @@
+#include "test.h"
+
+void ProjectTest::Run()
+{
+	string projectFilename ( "tests/data/project.xml" );
+	Project* project = new Project( projectFilename );
+	ARE_EQUAL(2, project->modules.size());
+}