Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
b6c141fe
Commit
b6c141fe
authored
Nov 17, 2010
by
vladlosev
Browse files
Fixes comments in sample7_unittest.cc.
parent
fe25aea9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
samples/sample7_unittest.cc
samples/sample7_unittest.cc
+9
-11
No files found.
samples/sample7_unittest.cc
View file @
b6c141fe
...
@@ -45,12 +45,11 @@
...
@@ -45,12 +45,11 @@
using
::
testing
::
TestWithParam
;
using
::
testing
::
TestWithParam
;
using
::
testing
::
Values
;
using
::
testing
::
Values
;
// As a general rule, tested objects should not be reused between tests.
// As a general rule, to prevent a test from affecting the tests that come
// Also, their constructors and destructors of tested objects can have
// after it, you should create and destroy the tested objects for each test
// side effects. Thus you should create and destroy them for each test.
// instead of reusing them. In this sample we will define a simple factory
// In this sample we will define a simple factory function for PrimeTable
// function for PrimeTable objects. We will instantiate objects in test's
// objects. We will instantiate objects in test's SetUp() method and
// SetUp() method and delete them in TearDown() method.
// delete them in TearDown() method.
typedef
PrimeTable
*
CreatePrimeTableFunc
();
typedef
PrimeTable
*
CreatePrimeTableFunc
();
PrimeTable
*
CreateOnTheFlyPrimeTable
()
{
PrimeTable
*
CreateOnTheFlyPrimeTable
()
{
...
@@ -62,11 +61,10 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
...
@@ -62,11 +61,10 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
return
new
PreCalculatedPrimeTable
(
max_precalculated
);
return
new
PreCalculatedPrimeTable
(
max_precalculated
);
}
}
// Inside the test body, fixture constructor, SetUp(), and TearDown()
// Inside the test body, fixture constructor, SetUp(), and TearDown() you
// you can refer to the test parameter by GetParam().
// can refer to the test parameter by GetParam(). In this case, the test
// In this case, the test parameter is a PrimeTableFactory interface pointer
// parameter is a factory function which we call in fixture's SetUp() to
// which we use in fixture's SetUp() to create and store an instance of
// create and store an instance of PrimeTable.
// PrimeTable.
class
PrimeTableTest
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
class
PrimeTableTest
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
public:
public:
virtual
~
PrimeTableTest
()
{
delete
table_
;
}
virtual
~
PrimeTableTest
()
{
delete
table_
;
}
...
...
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