1 /* 2 * Created by Martin on 19/07/2017. 3 * 4 * Distributed under the Boost Software License, Version 1.0. (See accompanying 5 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 8 #include "catch_totals.h" 9 10 namespace Catch { 11 operator -(Counts const & other) const12 Counts Counts::operator - ( Counts const& other ) const { 13 Counts diff; 14 diff.passed = passed - other.passed; 15 diff.failed = failed - other.failed; 16 diff.failedButOk = failedButOk - other.failedButOk; 17 return diff; 18 } 19 operator +=(Counts const & other)20 Counts& Counts::operator += ( Counts const& other ) { 21 passed += other.passed; 22 failed += other.failed; 23 failedButOk += other.failedButOk; 24 return *this; 25 } 26 total() const27 std::size_t Counts::total() const { 28 return passed + failed + failedButOk; 29 } allPassed() const30 bool Counts::allPassed() const { 31 return failed == 0 && failedButOk == 0; 32 } allOk() const33 bool Counts::allOk() const { 34 return failed == 0; 35 } 36 operator -(Totals const & other) const37 Totals Totals::operator - ( Totals const& other ) const { 38 Totals diff; 39 diff.assertions = assertions - other.assertions; 40 diff.testCases = testCases - other.testCases; 41 return diff; 42 } 43 operator +=(Totals const & other)44 Totals& Totals::operator += ( Totals const& other ) { 45 assertions += other.assertions; 46 testCases += other.testCases; 47 return *this; 48 } 49 delta(Totals const & prevTotals) const50 Totals Totals::delta( Totals const& prevTotals ) const { 51 Totals diff = *this - prevTotals; 52 if( diff.assertions.failed > 0 ) 53 ++diff.testCases.failed; 54 else if( diff.assertions.failedButOk > 0 ) 55 ++diff.testCases.failedButOk; 56 else 57 ++diff.testCases.passed; 58 return diff; 59 } 60 61 } 62