开发者

Testing with boost

Can someone write step by step what to do to start using testing facilities from boost? 开发者_开发百科For example I have a class:

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

and I would like to set test cases for multiplyByTwo fnc. How? In which files? What steps do I need to perform in order to run it?


Someone already has written this down for you - there is a 'hello world' introduction in the Boost docs.

For 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: There is a slightly more extensive tutorial here that should help when you start to taxonomize your tests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜