CppUTest
MockExpectedFunctionsList.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 #ifndef D_MockExpectedFunctionsList_h
29 #define D_MockExpectedFunctionsList_h
30 
32 class MockNamedValue;
33 
35 {
36 
37 public:
39  virtual ~MockExpectedFunctionsList();
40  virtual void deleteAllExpectationsAndClearList();
41 
42  virtual int size() const;
43  virtual int amountOfExpectationsFor(const SimpleString& name) const;
44  virtual int amountOfUnfulfilledExpectations() const;
45  virtual bool hasUnfullfilledExpectations() const;
46  virtual bool hasFulfilledExpectations() const;
47  virtual bool hasUnfulfilledExpectationsBecauseOfMissingParameters() const;
48  virtual bool hasExpectationWithName(const SimpleString& name) const;
49  virtual bool hasCallsOutOfOrder() const;
50  virtual bool isEmpty() const;
51 
52  virtual void addExpectedCall(MockExpectedFunctionCall* call);
53  virtual void addExpectations(const MockExpectedFunctionsList& list);
54  virtual void addExpectationsRelatedTo(const SimpleString& name, const MockExpectedFunctionsList& list);
55  virtual void addUnfilfilledExpectations(const MockExpectedFunctionsList& list);
56 
57  virtual void onlyKeepExpectationsRelatedTo(const SimpleString& name);
58  virtual void onlyKeepExpectationsWithParameter(const MockNamedValue& parameter);
59  virtual void onlyKeepExpectationsWithParameterName(const SimpleString& name);
60  virtual void onlyKeepExpectationsOnObject(void* objectPtr);
61  virtual void onlyKeepUnfulfilledExpectations();
62  virtual void onlyKeepUnfulfilledExpectationsRelatedTo(const SimpleString& name);
63  virtual void onlyKeepUnfulfilledExpectationsWithParameter(const MockNamedValue& parameter);
64  virtual void onlyKeepUnfulfilledExpectationsOnObject(void* objectPtr);
65 
66  virtual MockExpectedFunctionCall* removeOneFulfilledExpectation();
67  virtual MockExpectedFunctionCall* removeOneFulfilledExpectationWithIgnoredParameters();
68 
69  virtual void resetExpectations();
70  virtual void callWasMade(int callOrder);
71  virtual void wasPassedToObject();
72  virtual void parameterWasPassed(const SimpleString& parameterName);
73 
74  virtual SimpleString unfulfilledFunctionsToString(const SimpleString& linePrefix = "") const;
75  virtual SimpleString fulfilledFunctionsToString(const SimpleString& linePrefix = "") const;
76  virtual SimpleString missingParametersToString() const;
77 
78 protected:
79  virtual void pruneEmptyNodeFromList();
80 
82  {
83  public:
84  MockExpectedFunctionCall* expectedCall_;
85 
88  : expectedCall_(expectedCall), next_(NULL) {}
89  };
90 
91  virtual MockExpectedFunctionsListNode* findNodeWithCallOrderOf(int callOrder) const;
92 private:
94 
96 };
97 
98 #endif
Definition: SimpleString.h:46
Definition: MockExpectedFunctionCall.h:36
Definition: MockExpectedFunctionsList.h:34
Definition: MockNamedValue.h:69
Definition: MockExpectedFunctionsList.h:81