Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
2bee6da2
Commit
2bee6da2
authored
Oct 28, 2019
by
Abseil Team
Committed by
vslashg
Oct 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Editorial cleanup of the "write the main function" section PiperOrigin-RevId: 277102507
parent
755f853c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
primer.md
googletest/docs/primer.md
+11
-5
No files found.
googletest/docs/primer.md
View file @
2bee6da2
...
@@ -491,15 +491,18 @@ You can start from this boilerplate:
...
@@ -491,15 +491,18 @@ You can start from this boilerplate:
```
c++
```
c++
#include "this/package/foo.h"
#include "this/package/foo.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
my
{
namespace
project
{
namespace
{
namespace
{
// The fixture for testing class Foo.
// The fixture for testing class Foo.
class
FooTest
:
public
::
testing
::
Test
{
class
FooTest
:
public
::
testing
::
Test
{
protected
:
protected
:
// You can remove any or all of the following functions if
its body
// You can remove any or all of the following functions if
their bodies would
//
is
empty.
//
be
empty.
FooTest
()
{
FooTest
()
{
// You can do set-up work for each test here.
// You can do set-up work for each test here.
...
@@ -522,7 +525,8 @@ class FooTest : public ::testing::Test {
...
@@ -522,7 +525,8 @@ class FooTest : public ::testing::Test {
// before the destructor).
// before the destructor).
}
}
// Objects declared here can be used by all tests in the test suite for Foo.
// Class members declared here can be used by all tests in the test suite
// for Foo.
};
};
// Tests that the Foo::Bar() method does Abc.
// Tests that the Foo::Bar() method does Abc.
...
@@ -539,6 +543,8 @@ TEST_F(FooTest, DoesXyz) {
...
@@ -539,6 +543,8 @@ TEST_F(FooTest, DoesXyz) {
}
}
}
// namespace
}
// namespace
}
// namespace project
}
// namespace my
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
@@ -555,10 +561,10 @@ the [AdvancedGuide](advanced.md). You **must** call this function before calling
...
@@ -555,10 +561,10 @@ the [AdvancedGuide](advanced.md). You **must** call this function before calling
On Windows,
`InitGoogleTest()`
also works with wide strings, so it can be used
On Windows,
`InitGoogleTest()`
also works with wide strings, so it can be used
in programs compiled in
`UNICODE`
mode as well.
in programs compiled in
`UNICODE`
mode as well.
But maybe you think that writing all those
main()
functions is too much work? We
But maybe you think that writing all those
`main`
functions is too much work? We
agree with you completely, and that's why Google Test provides a basic
agree with you completely, and that's why Google Test provides a basic
implementation of main(). If it fits your needs, then just link your test with
implementation of main(). If it fits your needs, then just link your test with
gtest
\_
main
library and you are good to go.
the
`gtest_main`
library and you are good to go.
NOTE:
`ParseGUnitFlags()`
is deprecated in favor of
`InitGoogleTest()`
.
NOTE:
`ParseGUnitFlags()`
is deprecated in favor of
`InitGoogleTest()`
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment