This file is indexed.

/usr/include/cxxtest/Mock.h is in cxxtest 4.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*
-------------------------------------------------------------------------
 CxxTest: A lightweight C++ unit testing library.
 Copyright (c) 2008 Sandia Corporation.
 This software is distributed under the LGPL License v3
 For more information, see the COPYING file in the top CxxTest directory.
 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
 the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
*/

#ifndef __cxxtest__Mock_h__
#define __cxxtest__Mock_h__

namespace dummy_mock_ns {}

//
// The default namespace is T::
//
#ifndef CXXTEST_MOCK_NAMESPACE
#   define CXXTEST_MOCK_NAMESPACE T
#endif // CXXTEST_MOCK_NAMESPACE

//
// MockTraits: What to return when no mock object has been created
//
#define __CXXTEST_MOCK__TRAITS \
    namespace CXXTEST_MOCK_NAMESPACE \
    { \
        template<class T> \
        class MockTraits \
        { \
        public: \
            static T defaultValue() { return 0; } \
        }; \
    }

//
// extern "C" when needed
//
#ifdef __cplusplus
#   define CXXTEST_EXTERN_C extern "C"
#else
#   define CXXTEST_EXTERN_C
#endif // __cplusplus

//
// Prototypes: For "normal" headers
//
#define __CXXTEST_MOCK__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    namespace CXXTEST_MOCK_NAMESPACE { TYPE NAME ARGS; }

#define __CXXTEST_MOCK_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__PROTOTYPE( MOCK, void, NAME, ARGS, REAL, CALL )

#define __CXXTEST_SUPPLY__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    TYPE REAL ARGS;

#define __CXXTEST_SUPPLY_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__PROTOTYPE( MOCK, void, NAME, ARGS, REAL, CALL )

//
// Class declarations: For test files
//
#define __CXXTEST_MOCK__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        class Base_##MOCK : public CxxTest::Link \
        { \
        public: \
            Base_##MOCK(); \
            ~Base_##MOCK(); \
            bool setUp(); \
            bool tearDown(); \
         \
            static Base_##MOCK &current(); \
         \
            virtual TYPE NAME ARGS = 0; \
         \
        private: \
            static CxxTest::List _list; \
        }; \
         \
        class Real_##MOCK  : public Base_##MOCK \
        { \
        public: \
            TYPE NAME ARGS; \
        }; \
         \
        class _Unimplemented_##MOCK  : public Base_##MOCK \
        { \
        public: \
            TYPE NAME ARGS; \
        }; \
    }

#define __CXXTEST_MOCK_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__CLASS_DECLARATION( MOCK, void, NAME, ARGS, REAL, CALL )

#define __CXXTEST_SUPPLY__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        class Base_##MOCK : public CxxTest::Link \
        { \
        public: \
            Base_##MOCK(); \
            ~Base_##MOCK(); \
            bool setUp(); \
            bool tearDown(); \
         \
            static Base_##MOCK &current(); \
         \
            virtual TYPE NAME ARGS = 0; \
         \
        private: \
            static CxxTest::List _list; \
        }; \
         \
        class _Unimplemented_##MOCK  : public Base_##MOCK \
        { \
        public: \
            TYPE NAME ARGS; \
        }; \
    }

#define __CXXTEST_SUPPLY_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__CLASS_DECLARATION( MOCK, void, NAME, ARGS, REAL, CALL )

//
// Class implementation: For test source files
//
#define __CXXTEST_MOCK__COMMON_CLASS_IMPLEMENTATION( MOCK, NAME ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
         \
        CxxTest::List Base_##MOCK::_list = { 0, 0 }; \
         \
        Base_##MOCK::Base_##MOCK() { attach( _list ); } \
        Base_##MOCK::~Base_##MOCK() { detach( _list ); } \
        bool Base_##MOCK::setUp() { return true; } \
        bool Base_##MOCK::tearDown() { return true; } \
         \
        Base_##MOCK &Base_##MOCK::current() \
        { \
            if ( _list.empty() ) { \
                static _Unimplemented_##MOCK unimplemented; \
            } \
            return *(Base_##MOCK *)_list.tail(); \
        } \
    }

#define __CXXTEST_MOCK__CLASS_IMPLEMENTATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__COMMON_CLASS_IMPLEMENTATION( MOCK, NAME ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        TYPE Real_##MOCK::NAME ARGS \
        { \
            return REAL CALL; \
        } \
         \
        TYPE _Unimplemented_##MOCK::NAME ARGS \
        { \
            while ( false ) {\
                return NAME CALL; \
            } \
            __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ); \
            return MockTraits<TYPE>::defaultValue(); \
        } \
         \
        TYPE NAME ARGS \
        { \
            return Base_##MOCK::current().NAME CALL; \
        } \
    }

#define __CXXTEST_MOCK_VOID__CLASS_IMPLEMENTATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__COMMON_CLASS_IMPLEMENTATION( MOCK, NAME ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        void Real_##MOCK::NAME ARGS \
        { \
            REAL CALL; \
        } \
         \
        void _Unimplemented_##MOCK::NAME ARGS \
        { \
            while ( false ) { \
                NAME CALL; \
            } \
            __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ); \
        } \
         \
        void NAME ARGS \
        { \
            Base_##MOCK::current().NAME CALL; \
        } \
    }

#define __CXXTEST_SUPPLY__CLASS_IMPLEMENTATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__COMMON_CLASS_IMPLEMENTATION( MOCK, NAME ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        TYPE _Unimplemented_##MOCK::NAME ARGS \
        { \
            while ( false ) { \
                return NAME CALL; \
            } \
            __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ); \
            return MockTraits<TYPE>::defaultValue(); \
        } \
    } \
     \
    TYPE REAL ARGS \
    { \
        return CXXTEST_MOCK_NAMESPACE::Base_##MOCK::current().NAME CALL; \
    }

#define __CXXTEST_SUPPLY_VOID__CLASS_IMPLEMENTATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__COMMON_CLASS_IMPLEMENTATION( MOCK, NAME ) \
    namespace CXXTEST_MOCK_NAMESPACE { \
        void _Unimplemented_##MOCK::NAME ARGS \
        { \
            while ( false ) { \
                NAME CALL; \
            } \
            __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ); \
        } \
    } \
     \
    void REAL ARGS \
    { \
        CXXTEST_MOCK_NAMESPACE::Base_##MOCK::current().NAME CALL; \
    } \
 
//
// Error for calling mock function w/o object
//
#define __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ) \
    TS_FAIL( CXXTEST_MOCK_NAMESPACE_STR #NAME #ARGS " called with no " \
             CXXTEST_MOCK_NAMESPACE_STR "Base_" #NAME " object" ); \
 
#define CXXTEST_MOCK_NAMESPACE_STR __CXXTEST_STR(CXXTEST_MOCK_NAMESPACE) "::"
#define __CXXTEST_STR(X) __CXXTEST_XSTR(X)
#define __CXXTEST_XSTR(X) #X

#if defined(CXXTEST_MOCK_TEST_SOURCE_FILE)
//
// Test source file: Prototypes, class declarations and implementation
//
#include <cxxtest/TestSuite.h>

__CXXTEST_MOCK__TRAITS

#define CXXTEST_MOCK( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__CLASS_IMPLEMENTATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_MOCK_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__CLASS_IMPLEMENTATION( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__CLASS_IMPLEMENTATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__CLASS_IMPLEMENTATION( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#elif defined(CXXTEST_FLAGS) || defined(CXXTEST_RUNNING)
//
// Test file other than source: Prototypes and class declarations
//
#include <cxxtest/TestSuite.h>

__CXXTEST_MOCK__TRAITS;

#define CXXTEST_MOCK( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_MOCK_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__CLASS_DECLARATION( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__CLASS_DECLARATION( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#elif defined(CXXTEST_MOCK_REAL_SOURCE_FILE)
//
// Real source file: "Real" implementations
//
#define CXXTEST_MOCK( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    namespace CXXTEST_MOCK_NAMESPACE { TYPE NAME ARGS { return REAL CALL; } } using namespace dummy_mock_ns

#define CXXTEST_MOCK_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    namespace CXXTEST_MOCK_NAMESPACE { void NAME ARGS { REAL CALL; } } using namespace dummy_mock_ns

#else
//
// Ordinary header file: Just prototypes
//

#define CXXTEST_MOCK( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_MOCK_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_MOCK_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#define CXXTEST_SUPPLY_VOID( MOCK, NAME, ARGS, REAL, CALL ) \
    __CXXTEST_SUPPLY_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    using namespace dummy_mock_ns

#endif // Ordinary header file

//
// How to supply extern "C" functions
//
#define CXXTEST_SUPPLY_C( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    CXXTEST_EXTERN_C __CXXTEST_SUPPLY__PROTOTYPE( MOCK, TYPE, NAME, ARGS, REAL, CALL ) \
    CXXTEST_SUPPLY( MOCK, TYPE, NAME, ARGS, REAL, CALL )

#define CXXTEST_SUPPLY_VOID_C( MOCK, NAME, ARGS, REAL, CALL ) \
    CXXTEST_EXTERN_C __CXXTEST_SUPPLY_VOID__PROTOTYPE( MOCK, NAME, ARGS, REAL, CALL ) \
    CXXTEST_SUPPLY_VOID( MOCK, NAME, ARGS, REAL, CALL )

//
// Usually we mean the global namespace
//
#define CXXTEST_MOCK_GLOBAL( TYPE, NAME, ARGS, CALL ) \
    CXXTEST_MOCK( NAME, TYPE, NAME, ARGS, ::NAME, CALL )

#define CXXTEST_MOCK_VOID_GLOBAL( NAME, ARGS, CALL ) \
    CXXTEST_MOCK_VOID( NAME, NAME, ARGS, ::NAME, CALL )

#define CXXTEST_SUPPLY_GLOBAL( TYPE, NAME, ARGS, CALL ) \
    CXXTEST_SUPPLY( NAME, TYPE, NAME, ARGS, NAME, CALL )

#define CXXTEST_SUPPLY_VOID_GLOBAL( NAME, ARGS, CALL ) \
    CXXTEST_SUPPLY_VOID( NAME, NAME, ARGS, NAME, CALL )

#define CXXTEST_SUPPLY_GLOBAL_C( TYPE, NAME, ARGS, CALL ) \
    CXXTEST_SUPPLY_C( NAME, TYPE, NAME, ARGS, NAME, CALL )

#define CXXTEST_SUPPLY_VOID_GLOBAL_C( NAME, ARGS, CALL ) \
    CXXTEST_SUPPLY_VOID_C( NAME, NAME, ARGS, NAME, CALL )

//
// What to return when no mock object has been created.
// The default value of 0 usually works, but some cases may need this.
//
#define CXXTEST_MOCK_DEFAULT_VALUE( TYPE, VALUE ) \
    namespace CXXTEST_MOCK_NAMESPACE \
    { \
        template<> \
        class MockTraits<TYPE> \
        { \
        public: \
            static TYPE defaultValue() { return VALUE; } \
        }; \
    } using namespace dummy_mock_ns

#endif // __cxxtest__Mock_h__