51 lines
		
	
	
		
			676 B
		
	
	
	
		
			C++
		
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			676 B
		
	
	
	
		
			C++
		
	
	
| 
 | |
| 
 | |
| #include "Test.h"
 | |
| #include "TestResult.h"
 | |
| #include "TestRegistry.h"
 | |
| 
 | |
| 
 | |
| void TestRegistry::addTest (Test *test) 
 | |
| {
 | |
| 	instance ().add (test);
 | |
| }
 | |
| 
 | |
| 
 | |
| int TestRegistry::runAllTests (TestResult& result) 
 | |
| {
 | |
| 	instance ().run (result);
 | |
| }
 | |
| 
 | |
| 
 | |
| TestRegistry& TestRegistry::instance () 
 | |
| {
 | |
| 	static TestRegistry registry;
 | |
| 	return registry;
 | |
| }
 | |
| 
 | |
| 
 | |
| void TestRegistry::add (Test *test) 
 | |
| {
 | |
| 	if (tests == 0) {
 | |
| 		tests = test;
 | |
| 		return;
 | |
| 	}
 | |
| 	
 | |
| 	test->setNext (tests);
 | |
| 	tests = test;
 | |
| }
 | |
| 
 | |
| 
 | |
| int TestRegistry::run (TestResult& result) 
 | |
| {
 | |
| 	result.testsStarted ();
 | |
| 
 | |
| 	for (Test *test = tests; test != 0; test = test->getNext ())
 | |
| 		test->run (result);
 | |
| 	result.testsEnded ();
 | |
|   return result.getFailureCount();
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 |