Boost Testing

Can someone write step by step what to do in order to start using testing tools from enhancement? For example, I have a class:

class A
{
public:
int multiplyByTwo(const int input)
{
return input * 2;
}
};

and I would like to install test cases for multiplyByTwo fnc. How? In which files? What steps must be completed to start it?

+3
source share
1 answer

Someone already wrote this for you - there is a "hello world" in the Boost docs .

In your case, I think it should look something like this:

#include "A.hpp"
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE( my_test )
{
    my_class A( /* whatever you need to construct it right */ );

    BOOST_CHECK( A.multiply_by_two(2) == 4 );
}

EDIT: , , .

+4

Source: https://habr.com/ru/post/1767169/


All Articles