1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright 2009, Google Inc.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// All rights reserved.
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Redistribution and use in source and binary forms, with or without
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// modification, are permitted provided that the following conditions are
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// met:
7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//     * Redistributions of source code must retain the above copyright
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// notice, this list of conditions and the following disclaimer.
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//     * Redistributions in binary form must reproduce the above
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// copyright notice, this list of conditions and the following disclaimer
12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// in the documentation and/or other materials provided with the
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// distribution.
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//     * Neither the name of Google Inc. nor the names of its
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// contributors may be used to endorse or promote products derived from
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// this software without specific prior written permission.
17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Author: wan@google.com (Zhanyong Wan)
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Tests Google Test's throw-on-failure mode with exceptions disabled.
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// This program must be compiled with exceptions disabled.  It will be
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// invoked by gtest_throw_on_failure_test.py, and is expected to exit
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// with non-zero in the throw-on-failure mode or 0 otherwise.
37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
38731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#include "gtest/gtest.h"
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochint main(int argc, char** argv) {
41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  testing::InitGoogleTest(&argc, argv);
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // We want to ensure that people can use Google Test assertions in
44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // other testing frameworks, as long as they initialize Google Test
45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // properly and set the thrown-on-failure mode.  Therefore, we don't
46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // use Google Test's constructs for defining and running tests
47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // (e.g. TEST and RUN_ALL_TESTS) here.
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // In the throw-on-failure mode with exceptions disabled, this
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // assertion will cause the program to exit with a non-zero code.
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  EXPECT_EQ(2, 3);
52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // When not in the throw-on-failure mode, the control will reach
54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // here.
55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  return 0;
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
57