Index: ext/googletest/googletest/samples/sample4.cc =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -r3d5880c6661c3ed500e0c1c739a923ae9ede0364 --- ext/googletest/googletest/samples/sample4.cc (.../sample4.cc) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ext/googletest/googletest/samples/sample4.cc (.../sample4.cc) (revision 3d5880c6661c3ed500e0c1c739a923ae9ede0364) @@ -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 @@ -40,6 +38,16 @@ 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_);