1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
//
// verify_msg_exp_test.cpp - tests BOOST_VERIFY_MSG expansion
//
// Copyright (c) 2014 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/config.hpp>
#include <boost/current_function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
// default case, !NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> BOOST_ASSERT_MSG(x,"m")
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_default()
{
std::string v1 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x1, m1));
BOOST_TEST_EQ( v1, "BOOST_ASSERT_MSG(x1,m1)" );
}
// default case, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_default_ndebug()
{
std::string v2 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x2, m2));
BOOST_TEST_EQ( v2, "((void)(x2))" );
}
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled()
{
std::string v3 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x3, "m3"));
BOOST_TEST_EQ( v3, "((void)(x3))" );
}
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_disabled_ndebug()
{
std::string v4 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x4, "m4"));
BOOST_TEST_EQ( v4, "((void)(x4))" );
}
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_VERIFY_MSG(x,m) -> BOOST_ASSERT_MSG(x,m)
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_handler()
{
std::string v5 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x5, m5));
BOOST_TEST_EQ( v5, "BOOST_ASSERT_MSG(x5,m5)" );
}
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
#define NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_handler_ndebug()
{
std::string v6 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x6, m6));
BOOST_TEST_EQ( v6, "BOOST_ASSERT_MSG(x6,m6)" );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_debug_handler()
{
std::string v7 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x7, m7));
BOOST_TEST_EQ( v7, "BOOST_ASSERT_MSG(x7,m7)" );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
std::string v8 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x8, "m8"));
BOOST_TEST_EQ( v8, "((void)(x8))" );
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_disabled();
test_disabled_ndebug();
test_handler();
test_handler_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}
|