summaryrefslogtreecommitdiff
path: root/samples/sample4.cc
diff options
context:
space:
mode:
Diffstat (limited to 'samples/sample4.cc')
-rw-r--r--samples/sample4.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/samples/sample4.cc b/samples/sample4.cc
index ae44bda..b0ee609 100644
--- a/samples/sample4.cc
+++ b/samples/sample4.cc
@@ -28,8 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A sample program demonstrating using Google C++ testing framework.
-//
-// Author: wan@google.com (Zhanyong Wan)
#include <stdio.h>
@@ -40,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_);