#keywords C++, GoogleTest, 단위 테스트 작성자: [hyacinth] 작성일: [[Date(2013-01-09T16:42:08)]] [[TableOfContents]] http://www.gstatic.com/codesite/ph/images/search-48.gif?width=16 googletest - Google C++ Testing Framework http://code.google.com/p/googletest/ = 개발환경 설정 (for VS) = * 다운로드 * 라이브러리 빌드 /msvc/gtest-md.sln 솔루션 열어 Debug, Release 빌드. /msvc/Release/gtest.lib /msvc/Release/gtest_main-md.lib /msvc/Debug/gtest.lib /msvc/Debug/gtest_main-md.lib 생성 됨. * VC++ 디렉토리 포함 * 테스트 프로젝트 예 {{{#!gcode #include "stdafx.h" #include "gtest/gtest.h" #ifdef _DEBUG #pragma comment (lib, "gtestd.lib") #else #pragma comment (lib, "gtest.lib") #endif int test_func(int a) { return a; } TEST(test_func_test, TestFuncAbc) { EXPECT_EQ(120, test_func(120)); } GTEST_API_ int _tmain(int argc, _TCHAR* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } }}} ---- attachment:20130110_1.png Read more - http://code.google.com/p/googletest/wiki/Primer = Assertions = == Basic Assertions == {{{#!html

Fatal assertionNonfatal assertionVerifies
ASSERT_TRUE(condition);EXPECT_TRUE(condition);condition is true
ASSERT_FALSE(condition);EXPECT_FALSE(condition);condition is false

}}} == Binary Comparison == {{{#!html
Fatal assertionNonfatal assertionVerifies
ASSERT_EQ(expectedactual);EXPECT_EQ(expectedactual);expected == actual
ASSERT_NE(val1val2);EXPECT_NE(val1val2);val1 != val2
ASSERT_LT(val1val2);EXPECT_LT(val1val2);val1 < val2
ASSERT_LE(val1val2);EXPECT_LE(val1val2);val1 <= val2
ASSERT_GT(val1val2);EXPECT_GT(val1val2);val1 > val2
ASSERT_GE(val1val2);EXPECT_GE(val1val2);val1 >= val2
}}} == String Comparison == {{{#!html
Fatal assertionNonfatal assertionVerifies
ASSERT_STREQ(expected_stractual_str);EXPECT_STREQ(expected_stractual_str);the two C strings have the same content
ASSERT_STRNE(str1str2);EXPECT_STRNE(str1str2);the two C strings have different content
ASSERT_STRCASEEQ(expected_stractual_str);EXPECT_STRCASEEQ(expected_stractual_str);the two C strings have the same content, ignoring case
ASSERT_STRCASENE(str1str2);EXPECT_STRCASENE(str1str2);the two C strings have different content, ignoring case
}}} = 기타 = == Google Test UI == Google Test UI is an independent addition for googletest. 훌륭한 xUnit 스타일 c++ unit testing framework. 강력히 추천함. http://code.google.com/p/gtest-gbar/ https://raw.githubusercontent.com/ospector/gtest-gbar/master/wiki-imgs/smallScreen.png ---- CategoryDocument