Add assert_test3.cpp

This commit is contained in:
Peter Dimov
2026-06-27 15:22:28 +03:00
parent 7f0cfee2b7
commit b9860a738b
2 changed files with 65 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// Test for BOOST_ASSERT with both BOOST_DISABLE_ASSERTS and
// BOOST_ENABLE_ASSERT_HANDLER/BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#include <boost/core/lightweight_test.hpp>
#define BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
void test_disabled_handler()
{
BOOST_ASSERT( 1 );
BOOST_ASSERT_MSG( 1, "1" );
BOOST_ASSERT( 0 );
BOOST_ASSERT_MSG( 0, "0" );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#include <boost/assert.hpp>
void test_disabled_debug_handler()
{
BOOST_ASSERT( 1 );
BOOST_ASSERT_MSG( 1, "1" );
BOOST_ASSERT( 0 );
BOOST_ASSERT_MSG( 0, "0" );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
void test_disabled_both()
{
BOOST_ASSERT( 1 );
BOOST_ASSERT_MSG( 1, "1" );
BOOST_ASSERT( 0 );
BOOST_ASSERT_MSG( 0, "0" );
}
int main()
{
test_disabled_handler();
test_disabled_debug_handler();
test_disabled_both();
return boost::report_errors();
}