wiki:CMakeTestCompileFail

CMake Macro Reference: boost_test_compile_fail

The boost_test_compile_fail macro creates a Boost regression test that will be compiled, but compilation should fail. It is used to test, e.g., that certain disallowed syntax does in fact cause a compilation failure.

boost_test_compile_fail(testname 
                        [source1]
                        [COMPILE_FLAGS compileflags])

testname is the name of the test. source1 is the name of the source file that will be built. If no source file is provided, the file "testname.cpp" will be used instead.

The COMPILE_FLAGS argument provides additional arguments that will be passed to the compiler when building this test.

Example

The following invocation of the boost_test_compile_fail macro introduces a regression test that will attempt to compile function_test_fail1.cpp. The compilation should produce some error messages, in which case the regression test has succeeded.

boost_test_compile_fail(function_test_fail1)

This example is from libs/function/test/CMakeLists.txt.

Where Defined

This macro is defined in the Boost Testing module in tools/build/CMake/BoostTesting.cmake

Last modified 14 years ago Last modified on May 24, 2008, 12:18:04 PM
Note: See TracWiki for help on using the wiki.