catch_totals.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include "catch_totals.h"
  8. namespace Catch {
  9. Counts Counts::operator - ( Counts const& other ) const {
  10. Counts diff;
  11. diff.passed = passed - other.passed;
  12. diff.failed = failed - other.failed;
  13. diff.failedButOk = failedButOk - other.failedButOk;
  14. return diff;
  15. }
  16. Counts& Counts::operator += ( Counts const& other ) {
  17. passed += other.passed;
  18. failed += other.failed;
  19. failedButOk += other.failedButOk;
  20. return *this;
  21. }
  22. std::size_t Counts::total() const {
  23. return passed + failed + failedButOk;
  24. }
  25. bool Counts::allPassed() const {
  26. return failed == 0 && failedButOk == 0;
  27. }
  28. bool Counts::allOk() const {
  29. return failed == 0;
  30. }
  31. Totals Totals::operator - ( Totals const& other ) const {
  32. Totals diff;
  33. diff.assertions = assertions - other.assertions;
  34. diff.testCases = testCases - other.testCases;
  35. return diff;
  36. }
  37. Totals& Totals::operator += ( Totals const& other ) {
  38. assertions += other.assertions;
  39. testCases += other.testCases;
  40. return *this;
  41. }
  42. Totals Totals::delta( Totals const& prevTotals ) const {
  43. Totals diff = *this - prevTotals;
  44. if( diff.assertions.failed > 0 )
  45. ++diff.testCases.failed;
  46. else if( diff.assertions.failedButOk > 0 )
  47. ++diff.testCases.failedButOk;
  48. else
  49. ++diff.testCases.passed;
  50. return diff;
  51. }
  52. }