GoogleTest_testmain.cpp

#include "gtunit.h"
 
GT_TEST_FUNC(TEST1, Test1)
{
	new int; // メモリリーク
}
 
class Foo : public GT_FORM
{
protected :
	int m_num;
 
public :
	Foo()
		:m_num( 0 )
	{
	}
 
	void Print()
	{
		std::cout << m_num << std::endl;
	}
};
 
GT_TEST_CLASS(Foo, Print)
{
	m_num = 100;
 
	Print();
}
 
GT_TEST_CLASS(Foo, NumEqual)
{
	ASSERT_EQ( 0, m_num );
 
	ASSERT_NE( 1, m_num );
}
/*
Running main() from gtest_main.cc
[==========] Running 3 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from TEST1
[ RUN      ] TEST1.Test1
d:\programming\googletest\main.cpp(3): error: Value of: alloc.Check()
  Actual: false
Expected: true
MEMORY_LEAK!!
FILE: d:\programming\googletest\main.cpp
 LINE: 5
[  FAILED  ] TEST1.Test1
[----------] 2 tests from Foo
[ RUN      ] Foo.Print
100
[       OK ] Foo.Print
[ RUN      ] Foo.NumEqual
[       OK ] Foo.NumEqual
[----------] Global test environment tear-down
[==========] 3 tests from 2 test cases ran.
[  PASSED  ] 2 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] TEST1.Test1
 
 1 FAILED TEST
続行するには何かキーを押してください . . .
*/
最終更新:2009年02月14日 16:15
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。