
I do not think I was clear enough. Let's look at the example again...
void infinite_loop() { // unit test framework can break infinite loops by timeout #ifdef __unix // don't have timeout on other platforms BOOST_CHECKPOINT("About to enter an infinite loop!"); while(1); #else BOOST_MESSAGE( "Timeout support is not implemented on your platform"); #endif }
If I were to write a similar test, I would rather it look something like...
void infinite_loop() { // unit test framework can break infinite loops by timeout #ifdef BOOST_TEST_HAS_TIMEOUT BOOST_CHECKPOINT("About to enter an infinite loop!"); while(1); #else BOOST_MESSAGE( "Timeout support is not implemented on your platform"); #endif }
Example uses ifdef because: 1. It used to demonstrate that timeout support is not supported everywhere 2. We know for sure it will hang if run on a system that does not support timeout You as a user shouldn't in general expect it and if it does hang and your system doesn't support timeout you will have to interrupt it yourself. The only reason to use ifdef is the case when you are doing portable development and willing to ignore possible infinite loop on some configurations for the sake of ability to run a test as a part of regression suite (without human intervention). Is it really the case? Gennadiy