Imported Upstream version 1.12.0
[platform/upstream/gtest.git] / googletest / test / gtest_assert_by_exception_test.cc
index ada4cb3..f507eac 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-
 // Tests Google Test's assert-by-exception mode with exceptions enabled.
 
-#include "gtest/gtest.h"
-
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+
 #include <stdexcept>
 
+#include "gtest/gtest.h"
+
 class ThrowListener : public testing::EmptyTestEventListener {
   void OnTestPartResult(const testing::TestPartResult& result) override {
     if (result.type() == testing::TestPartResult::kFatalFailure) {
@@ -55,9 +55,7 @@ void Fail(const char* msg) {
   exit(1);
 }
 
-static void AssertFalse() {
-  ASSERT_EQ(2, 3) << "Expected failure";
-}
+static void AssertFalse() { ASSERT_EQ(2, 3) << "Expected failure"; }
 
 // Tests that an assertion failure throws a subclass of
 // std::runtime_error.
@@ -65,21 +63,21 @@ TEST(Test, Test) {
   // A successful assertion shouldn't throw.
   try {
     EXPECT_EQ(3, 3);
-  } catch(...) {
+  } catch (...) {
     Fail("A successful assertion wrongfully threw.");
   }
 
   // A successful assertion shouldn't throw.
   try {
     EXPECT_EQ(3, 4);
-  } catch(...) {
+  } catch (...) {
     Fail("A failed non-fatal assertion wrongfully threw.");
   }
 
   // A failed assertion should throw.
   try {
     AssertFalse();
-  } catch(const testing::AssertionException& e) {
+  } catch (const testing::AssertionException& e) {
     if (strstr(e.what(), "Expected failure") != nullptr) throw;
 
     printf("%s",
@@ -87,7 +85,7 @@ TEST(Test, Test) {
            "but the message is incorrect.  Instead of containing \"Expected "
            "failure\", it is:\n");
     Fail(e.what());
-  } catch(...) {
+  } catch (...) {
     Fail("A failed assertion threw the wrong type of exception.");
   }
   Fail("A failed assertion should've thrown but didn't.");
@@ -95,9 +93,7 @@ TEST(Test, Test) {
 
 int kTestForContinuingTest = 0;
 
-TEST(Test, Test2) {
-  kTestForContinuingTest = 1;
-}
+TEST(Test, Test2) { kTestForContinuingTest = 1; }
 
 int main(int argc, char** argv) {
   testing::InitGoogleTest(&argc, argv);