TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / backward-cpp / test / test.cpp
1 /*
2  * test/test.cpp
3  * Copyright 2013 Google Inc. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23
24 #include <iostream>
25 #include <stdexcept>
26 #include <cstdlib>
27 #include "test/test.hpp"
28
29 TEST (empty_test) { }
30
31 TEST_FAIL_ASSERT (fail_assert) {
32         ASSERT(1 == 2);
33 }
34
35 TEST_FAIL_ASSERT (fail_assert_ge) {
36         ASSERT_GE(4, 5);
37 }
38
39 TEST_UNCAUGHT_EXCEPTION (uncaught_exception) {
40         throw std::runtime_error("some random runtime error");
41 }
42
43 TEST_UNCAUGHT_EXCEPTION (uncaught_exception_int) {
44         throw 42;
45 }
46
47 TEST_SEGFAULT (segfault) {
48         char* a = 0;
49         char b = a[42];
50         std::cout << "result: " << b << std::endl;
51 }
52
53 TEST_ABORT (abort) {
54         abort();
55 }
56
57 TEST (catch_int) {
58         ASSERT_THROW({throw 42;}, int);
59 }
60
61 TEST_FAIL_ASSERT (fail_catch_int) {
62         ASSERT_THROW({}, int);
63 }
64
65 TEST_FAIL_ASSERT (fail_no_throw) {
66         ASSERT_NO_THROW({throw 42;});
67 }
68
69 TEST (any_throw) {
70         ASSERT_ANY_THROW({throw 42;});
71 }
72
73 TEST_FAIL_ASSERT (fail_any_throw) {
74         ASSERT_ANY_THROW({});
75 }