diff options
Diffstat (limited to 'googletest/samples/sample4.cc')
-rw-r--r-- | googletest/samples/sample4.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/googletest/samples/sample4.cc b/googletest/samples/sample4.cc index 2f7c87a..724bcb5 100644 --- a/googletest/samples/sample4.cc +++ b/googletest/samples/sample4.cc @@ -38,6 +38,16 @@ int Counter::Increment() { 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. void Counter::Print() const { printf("%d", counter_); |