Chinaunix首页 | 论坛 | 博客
  • 博客访问: 586739
  • 博文数量: 201
  • 博客积分: 3076
  • 博客等级: 中校
  • 技术积分: 2333
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-02 19:44
文章分类

全部博文(201)

文章存档

2010年(118)

2009年(83)

我的朋友

分类:

2010-07-11 14:56:39



svn checkout ....

configure
make
make install

默认装在 /usr/local/include /usr/local/lib 下
有两个库 libgtest 和 libgtest_main

使用时 gcc -I.. -L... -l...  .................

------------------------------------------------------------------------

Once you are able to compile the Google Test library, you should create a project or build target for your test program. Make sure you have GTEST_ROOT/include in the header search path so that the compiler can find when compiling your test. Set up your test project to link with the Google Test library

test program -> test cases -> tests

ASSERT_*
EXPECT_*

<<

ASSERT_EQ(expected, actual);

the arguments' evaluation order is undefined (i.e. the compiler is free to choose any order) and your code should not depend on any particular argument evaluation order.

ASSERT_EQ() does pointer equality on pointers. If used on two C strings, it tests if they are in the same memory location, not if they have the same value. Therefore, if you want to compare C strings (e.g. const char*) by value, use ASSERT_STREQ() , which will be described later on. In particular, to assert that a C string is NULL, use ASSERT_STREQ(NULL, c_string) . However, to compare two string objects, you should use ASSERT_EQ.

TEST(test_case_name, test_name) {
 
... test body ...
}

fixtures:
class Footest : public ::testing::test

TEST_F(test_case_name, test_name) {
 
... test body ...
}


The ::testing::InitGoogleTest() function parses the command
line for Google Test flags, and removes all recognized flags. This
allows the user to control a test program's behavior via various flags,
which we'll cover in .
You must call this function before calling RUN_ALL_TESTS(), or
the flags won't be properly initialized.

int main(int argc, char **argv) {
 
::testing::InitGoogleTest(&argc, argv);
 
return RUN_ALL_TESTS();
}

gtest_main library

---------------------------------------------------
advanced guide:

:

SUCCEED();
FAIL();
ADD_FAILURE();

Fatal assertion Nonfatal assertion Verifies
ASSERT_THROW(statement, exception_type); EXPECT_THROW(statement, exception_type); statement throws an exception of the given type
ASSERT_ANY_THROW(statement); EXPECT_ANY_THROW(statement); statement throws an exception of any type
ASSERT_NO_THROW(statement); EXPECT_NO_THROW(statement); statement doesn't throw any exception

阅读(654) | 评论(0) | 转发(0) |
0

上一篇:SVN,HG,GIT命令对照

下一篇:html学习笔记

给主人留下些什么吧!~~