mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 05:59:32 +01:00 
			
		
		
		
	Expanded the practical example in slow-compiles documentation
This commit is contained in:
		@@ -42,6 +42,21 @@ TEST_CASE( "Factorials are computed", "[factorial]" ) {
 | 
			
		||||
 | 
			
		||||
After compiling `tests-main.cpp` once, it is enough to link it with separately compiled `tests-factorial.cpp`. This means that adding more tests to `tests-factorial.cpp`, will not result in recompiling Catch's main and the resulting compilation times will decrease substantially.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
$ g++ tests-main.cpp -c
 | 
			
		||||
$ g++ tests-main.o tests-factorial.cpp -o tests && ./tests -r compact
 | 
			
		||||
Passed 1 test case with 4 assertions.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Now, the next time we change the file `tests-factorial.cpp` (say we add `REQUIRE( Factorial(0) == 1)`), it is enough to recompile the tests instead of recompiling main as well:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
$ g++ tests-main.o tests-factorial.cpp -o tests
 | 
			
		||||
$ g++ tests-main.o tests-factorial.cpp -o tests && ./tests -r compact
 | 
			
		||||
tests-factorial.cpp:11: failed: Factorial(0) == 1 for: 0 == 1
 | 
			
		||||
Failed 1 test case, failed 1 assertion.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user