NetBurner 3.1
MockActualCall.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_MockActualCall_h
29 #define D_MockActualCall_h
30 
31 #include "CppUTest/TestHarness.h"
32 #include "CppUTestExt/MockNamedValue.h"
33 #include "CppUTestExt/MockExpectedCallsList.h"
34 
35 class MockFailureReporter;
36 class MockFailure;
37 
38 class MockActualCall
39 {
40 public:
41  MockActualCall();
42  virtual ~MockActualCall();
43 
44  virtual MockActualCall& withName(const SimpleString& name)=0;
45  virtual MockActualCall& withCallOrder(unsigned int callOrder)=0;
46  MockActualCall& withParameter(const SimpleString& name, bool value) { return withBoolParameter(name, value); }
47  MockActualCall& withParameter(const SimpleString& name, int value) { return withIntParameter(name, value); }
48  MockActualCall& withParameter(const SimpleString& name, unsigned int value) { return withUnsignedIntParameter(name, value); }
49  MockActualCall& withParameter(const SimpleString& name, long int value) { return withLongIntParameter(name, value); }
50  MockActualCall& withParameter(const SimpleString& name, unsigned long int value) { return withUnsignedLongIntParameter(name, value); }
51  MockActualCall& withParameter(const SimpleString& name, double value) { return withDoubleParameter(name, value); }
52  MockActualCall& withParameter(const SimpleString& name, const char* value) { return withStringParameter(name, value); }
53  MockActualCall& withParameter(const SimpleString& name, void* value) { return withPointerParameter(name, value); }
54  MockActualCall& withParameter(const SimpleString& name, void (*value)()) { return withFunctionPointerParameter(name, value); }
55  MockActualCall& withParameter(const SimpleString& name, const void* value) { return withConstPointerParameter(name, value); }
56  MockActualCall& withParameter(const SimpleString& name, const unsigned char* value, size_t size) { return withMemoryBufferParameter(name, value, size); }
57  virtual MockActualCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value)=0;
58  virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output)=0;
59  virtual MockActualCall& withOutputParameterOfType(const SimpleString& typeName, const SimpleString& name, void* output)=0;
60 
61  virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value)=0;
62  virtual MockActualCall& withIntParameter(const SimpleString& name, int value)=0;
63  virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value)=0;
64  virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value)=0;
65  virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value)=0;
66  virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value)=0;
67  virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value)=0;
68  virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value)=0;
69  virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)())=0;
70  virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value)=0;
71  virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size)=0;
72 
73  virtual bool hasReturnValue()=0;
74  virtual MockNamedValue returnValue()=0;
75 
76  virtual bool returnBoolValueOrDefault(bool default_value)=0;
77  virtual bool returnBoolValue()=0;
78 
79  virtual int returnIntValueOrDefault(int default_value)=0;
80  virtual int returnIntValue()=0;
81 
82  virtual unsigned long int returnUnsignedLongIntValue()=0;
83  virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int default_value)=0;
84 
85  virtual long int returnLongIntValue()=0;
86  virtual long int returnLongIntValueOrDefault(long int default_value)=0;
87 
88  virtual unsigned int returnUnsignedIntValue()=0;
89  virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value)=0;
90 
91  virtual const char * returnStringValueOrDefault(const char * default_value)=0;
92  virtual const char * returnStringValue()=0;
93 
94  virtual double returnDoubleValue()=0;
95  virtual double returnDoubleValueOrDefault(double default_value)=0;
96 
97  virtual void * returnPointerValue()=0;
98  virtual void * returnPointerValueOrDefault(void * default_value)=0;
99 
100  virtual const void * returnConstPointerValue()=0;
101  virtual const void * returnConstPointerValueOrDefault(const void * default_value)=0;
102 
103  virtual void (*returnFunctionPointerValue())()=0;
104  virtual void (*returnFunctionPointerValueOrDefault(void (*default_value)()))()=0;
105 
106  virtual MockActualCall& onObject(const void* objectPtr)=0;
107 };
108 
109 #endif