CppUTest
MockFailure.h
1 /*
2  * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the <organization> nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 
29 #ifndef D_MockFailure_h
30 #define D_MockFailure_h
31 
32 #include "CppUTest/TestFailure.h"
33 
36 class MockNamedValue;
37 class MockFailure;
38 
40 {
41 protected:
42  bool crashOnFailure_;
43 public:
44  MockFailureReporter() : crashOnFailure_(false){}
45  virtual ~MockFailureReporter() {}
46 
47  virtual void failTest(const MockFailure& failure);
48  virtual UtestShell* getTestToFail();
49  virtual int getAmountOfTestFailures();
50 
51  virtual void crashOnFailure() {crashOnFailure_ = true; }
52 };
53 
54 class MockFailure : public TestFailure
55 {
56 public:
57  MockFailure(UtestShell* test);
58  virtual ~MockFailure(){}
59 protected:
60  void addExpectationsAndCallHistory(const MockExpectedFunctionsList& expectations);
61  void addExpectationsAndCallHistoryRelatedTo(const SimpleString& function, const MockExpectedFunctionsList& expectations);
62 };
63 
65 {
66 public:
69 };
70 
72 {
73 public:
76 };
77 
79 {
80 public:
81  MockCallOrderFailure(UtestShell* test, const MockExpectedFunctionsList& expectations);
82  virtual ~MockCallOrderFailure(){}
83 };
84 
86 {
87 public:
88  MockUnexpectedParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedFunctionsList& expectations);
90 };
91 
93 {
94 public:
95  MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedFunctionsList& expectations);
97 };
98 
100 {
101 public:
104 };
105 
107 {
108 public:
109  MockUnexpectedObjectFailure(UtestShell* test, const SimpleString& functionName, void* expected, const MockExpectedFunctionsList& expectations);
110  virtual ~MockUnexpectedObjectFailure(){}
111 };
112 
114 {
115 public:
116  MockExpectedObjectDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedFunctionsList& expectations);
118 };
119 
120 #endif
Definition: MockFailure.h:113
Definition: MockFailure.h:71
Definition: MockFailure.h:85
Definition: SimpleString.h:46
Definition: TestFailure.h:44
Definition: Utest.h:61
Definition: MockFailure.h:78
Definition: MockExpectedFunctionsList.h:34
Definition: MockFailure.h:54
Definition: MockFailure.h:64
Definition: MockFailure.h:92
Definition: MockFailure.h:99
Definition: MockNamedValue.h:69
Definition: MockFailure.h:106
Definition: MockActualFunctionCall.h:38
Definition: MockFailure.h:39