使BOOST_TEST_MESSAGE显示在屏幕上

Either set the environment variable BOOST_TEST_LOG_LEVEL to message when running your test binary:

BOOST_TEST_LOG_LEVEL=message <your_test>


命令行添加如下参数:

<your_test> --log_level=message

 

The macro BOOST_TEST_MESSAGE is intended to be used for the purpose of injecting an additional message into the UTF test log. These messages are not intended to indicate any error or warning conditions, but rather as information/status notifications. The macro signature is as follows:

BOOST_TEST_MESSAGE(test_message)

The test_message argument can be as simple as C string literal or any custom expression that you can produce with in a manner similar to standard iostream operation.

[Important] Important

Messages generated by this tool do not appear in test log output with default value of the active log level threshold. For these messages to appear the active log level threshold has to be set to a value below or equal to "message".

Example�27.�BOOST_TEST_MESSAGE usage

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

//____________________________________________________________________________//

BOOST_AUTO_TEST_CASE( test_init )
{
    int current_time = 0; // real call is required here

    BOOST_TEST_MESSAGE( "Testing initialization :" );
    BOOST_TEST_MESSAGE( "Current time:" << current_time );
}

//____________________________________________________________________________//

BOOST_AUTO_TEST_CASE( test_update )
{
    std::string field_name = "Volume";
    int         value      = 100;

    BOOST_TEST_MESSAGE( "Testing update :" );
    BOOST_TEST_MESSAGE( "Update " << field_name << " with " << value );
}

//____________________________________________________________________________//

来源

https://www.it1352.com/1881186.html

 

https://www.boost.org/doc/libs/1_58_0/libs/test/doc/html/utf/user-guide/test-output/BOOST_TEST_MESSAGE.html

posted on 2021-01-29 20:08  我尽量尽力而为  阅读(249)  评论(0)    收藏  举报

导航