cmake_minimum_required(VERSION3.5)# Set the project nameproject(boost_unit_test)# find a boost install with the libraries unit_test_frameworkfind_package(Boost1.46.1REQUIRED COMPONENTS unit_test_framework)# Add an library for the example classesadd_library(example_boost_unit_test Reverse.cpp Palin...
# find a boost install with the libraries unit_test_framework find_package(Boost 1.46.1 REQUIRED COMPONENTS unit_test_framework) # Add an library for the example classes add_library(example_boost_unit_test Reverse.cpp Palindrome.cpp ) target_include_directories(example_boost_unit_test PUBLIC ${C...
BOOST_AUTO_TEST_SUITE( s_suit ) BOOST_AUTO_TEST_SUITE_END() 一个最简单的测试 #defineBOOST_TEST_MODULE example #include"boost/test/unit_test.hpp" BOOST_AUTO_TEST_SUITE(s_suit) BOOST_AUTO_TEST_CASE(t_case1) { BOOST_CHECK_EQUAL(1,1); } BOOST_AUTO_TEST_SUITE_END() 注意:这里的 #de...
编译时同时需要链接-lboost_unit_test_framework 测试夹具 前面说测试夹具就好比c++的构造函数和析构函数,也可以理解为在执行测试之前设置一个环境,在测试完成时清除它。 看两个栗子吧: #define BOOST_TEST_MODULE example #include <boost/test/included/unit_test.hpp> #include <iostream> struct F { F():i...
BOOST_AUTO_TEST_CASE(test_example_2) { // ... } BOOST_AUTO_TEST_SUITE_END() // 执行测试 int main(int argc, char** argv) { return boost::unit_test::unit_test_main(&init_unit_test, argc, argv); } 在进行Boost单元测试时,可以结合腾讯云的产品进行测试环境的搭建和管理。例如,可以...
Google Test:Google在去年开源的测试框架,据说其内部上千个项目均采用该框架进行单元测试。 2. Boost Test起步 先来看一个简单的Boost Test示例(来自Boost文档): 1#define BOOST_TEST_MODULE example 2 3#include <boost/test/unit_test.hpp> 4 5
1 #define BOOST_TEST_MODULE Example // 主测试套件,一个测试项目中只能有一个主测试套件 2 3 #include "stdafx.h"4 #include "D:\VSProject\BoostUnitTest\BoostUnitTest\Tested\tested.h"// 待测工程头文件 5 6 BOOST_AUTO_TEST_SUITE(Tested_test)// 测试套件 7 8 BOOST_AUTO_TEST_CASE...
#defineBOOST_TEST_MODULESuite_example#include<boost/test/unit_test.hpp>BOOST_AUTO_TEST_SUITE(TwoTwoFour_suite)BOOST_AUTO_TEST_CASE(testPlus){BOOST_CHECK_EQUAL(2+2,4);}BOOST_AUTO_TEST_CASE(testMult){BOOST_CHECK_EQUAL(2*2,4);}BOOST_AUTO_TEST_SUITE_END() ...
1.项目有main函数时,需要一下宏定制main函数,缺少入口(main)的话无法自动单元测试: #define BOOST_TEST_NO_MAIN #define BOOST_TEST_ALTERNATIVE_INIT_API 2.多个文件时 主文件需: #include <boost/test/included/unit_test.hpp> 从文件用: #include <boost/test/unit_test.hpp> ...
example- Boost.Log examples include- Interface headers of Boost.Log src- Compilable source code of Boost.Log test- Boost.Log unit tests More information Documentation Ask questions Report bugs. Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample ...