kota2426 @Wiki

Unit Test Framework

最終更新:

匿名ユーザー

- view
だれでも歓迎! 編集
main関数はリンクするライブラリの中に実装されている。

#include "stdafx.h"
#include <boost/test/unit_test.hpp>
 
void my_test_function1()
{
	...
}
void my_test_function2()
{
	...
}

boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[])
{
	boost::unit_test::test_suite* test = BOOST_TEST_SUITE("testsuite_name");
	test->add(BOOST_TEST_CASE(&my_test_function1));
	test->add(BOOST_TEST_CASE(&my_test_function2));

	return test;
}

MSVCの場合

MSVCであればリンカの設定の代わりに以下のコードを埋めておくことができる
#ifdef _MT
	#ifdef  _DEBUG
		#pragma comment(lib,"libboost_unit_test_framework-vc71-mt-sgd.lib")
	#else //_DEBUG
		#pragma comment(lib,"libboost_unit_test_framework-vc71-mt-s.lib")
	#endif//_DEBUG
#else//_MT
	#ifdef  _DEBUG
		#pragma comment(lib,"libboost_unit_test_framework-vc71-sgd.lib")
	#else //_DEBUG
		#pragma comment(lib,"libboost_unit_test_framework-vc71-s.lib")
	#endif//_DEBUG
#endif//_MT
ビルド後のイベントに以下のコマンドを追加しておくと
ビルドのたびにテストが起動。
"$(TargetDir)$(TargetName).exe" --log_level=messages --build_info=yes (次行に続く)
            --result_code=no --report_level=short --catch_system_errors=no

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

添付ファイル
目安箱バナー