From 7c81bc611c7ebf50b9d1ce3f4b6d400bfbca139f Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 27 Jul 2013 11:50:21 -0700 Subject: [PATCH] Add UnitTest::anyTestsFailed() --- .../modules/beast_core/diagnostic/beast_UnitTest.cpp | 11 +++++++++++ .../modules/beast_core/diagnostic/beast_UnitTest.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp index 0a5241dd1..42ed690d3 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp @@ -127,6 +127,17 @@ const UnitTests::TestResult* UnitTests::getResult (int index) const noexcept return results [index]; } +bool UnitTests::anyTestsFailed () const noexcept +{ + for (int i = 0; i < results.size (); ++i) + { + if (results [i]->failures > 0) + return true; + } + + return false; +} + void UnitTests::resultsUpdated() { } diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h index bb300b364..43498f9c3 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h @@ -279,6 +279,9 @@ public: */ const TestResult* getResult (int index) const noexcept; + /** Returns `true` if any test failed. */ + bool anyTestsFailed () const noexcept; + protected: /** Called when the list of results changes. You can override this to perform some sort of behaviour when results are added.