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
5891bb53
Commit
5891bb53
authored
Aug 20, 2018
by
misterg
Committed by
Gennadiy Civil
Aug 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
googletest export
- 209457486 Import of OSS PR,
https://github.com/google/googletest/pu
... by misterg <misterg@google.com> PiperOrigin-RevId: 209457486
parent
9404c5ae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
sample4.cc
googletest/samples/sample4.cc
+10
-0
sample4.h
googletest/samples/sample4.h
+3
-0
sample4_unittest.cc
googletest/samples/sample4_unittest.cc
+5
-0
No files found.
googletest/samples/sample4.cc
View file @
5891bb53
...
@@ -38,6 +38,16 @@ int Counter::Increment() {
...
@@ -38,6 +38,16 @@ int Counter::Increment() {
return
counter_
++
;
return
counter_
++
;
}
}
// Returns the current counter value, and decrements it.
// counter can not be less than 0, return 0 in this case
int
Counter
::
Decrement
()
{
if
(
counter_
==
0
)
{
return
counter_
;
}
else
{
return
counter_
--
;
}
}
// Prints the current counter value to STDOUT.
// Prints the current counter value to STDOUT.
void
Counter
::
Print
()
const
{
void
Counter
::
Print
()
const
{
printf
(
"%d"
,
counter_
);
printf
(
"%d"
,
counter_
);
...
...
googletest/samples/sample4.h
View file @
5891bb53
...
@@ -43,6 +43,9 @@ class Counter {
...
@@ -43,6 +43,9 @@ class Counter {
// Returns the current counter value, and increments it.
// Returns the current counter value, and increments it.
int
Increment
();
int
Increment
();
// Returns the current counter value, and decrements it.
int
Decrement
();
// Prints the current counter value to STDOUT.
// Prints the current counter value to STDOUT.
void
Print
()
const
;
void
Print
()
const
;
};
};
...
...
googletest/samples/sample4_unittest.cc
View file @
5891bb53
...
@@ -37,12 +37,17 @@ namespace {
...
@@ -37,12 +37,17 @@ namespace {
TEST
(
Counter
,
Increment
)
{
TEST
(
Counter
,
Increment
)
{
Counter
c
;
Counter
c
;
// Test that counter 0 returns 0
EXPECT_EQ
(
0
,
c
.
Decrement
());
// EXPECT_EQ() evaluates its arguments exactly once, so they
// EXPECT_EQ() evaluates its arguments exactly once, so they
// can have side effects.
// can have side effects.
EXPECT_EQ
(
0
,
c
.
Increment
());
EXPECT_EQ
(
0
,
c
.
Increment
());
EXPECT_EQ
(
1
,
c
.
Increment
());
EXPECT_EQ
(
1
,
c
.
Increment
());
EXPECT_EQ
(
2
,
c
.
Increment
());
EXPECT_EQ
(
2
,
c
.
Increment
());
EXPECT_EQ
(
3
,
c
.
Decrement
());
}
}
}
// namespace
}
// namespace
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