• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thetic / cpputest / 15061113697

16 May 2025 02:10AM UTC coverage: 99.075% (-0.2%) from 99.279%
15061113697

push

github

Steven-Butz
Add support for long int and unsigned long int in Mock setData

0 of 14 new or added lines in 2 files covered. (0.0%)

6751 of 6814 relevant lines covered (99.08%)

46576.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.75
/src/CppUTestExt/MockSupport.cpp
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
#include "CppUTest/TestHarness.h"
29
#include "CppUTestExt/MockSupport.h"
30
#include "CppUTestExt/MockActualCall.h"
31
#include "CppUTestExt/MockExpectedCall.h"
32
#include "CppUTestExt/MockFailure.h"
33

34
#define MOCK_SUPPORT_SCOPE_PREFIX "!!!$$$MockingSupportScope$$$!!!"
35

36
static MockSupport global_mock;
37

38
MockSupport& mock(const SimpleString& mockName, MockFailureReporter* failureReporterForThisCall)
5,337✔
39
{
40
    MockSupport& mock_support = (mockName != "") ? *global_mock.getMockSupportScope(mockName) : global_mock;
5,337✔
41
    mock_support.setActiveReporter(failureReporterForThisCall);
5,337✔
42
    mock_support.setDefaultComparatorsAndCopiersRepository();
5,337✔
43
    return mock_support;
5,337✔
44
}
45

46
MockSupport::MockSupport(const SimpleString& mockName)
105✔
47
    :
48
        actualCallOrder_(0),
105✔
49
        expectedCallOrder_(0),
105✔
50
        strictOrdering_(false),
105✔
51
        activeReporter_(NULLPTR),
105✔
52
        standardReporter_(&defaultReporter_),
105✔
53
        ignoreOtherCalls_(false),
105✔
54
        enabled_(true),
105✔
55
        lastActualFunctionCall_(NULLPTR),
105✔
56
        mockName_(mockName),
105✔
57
        tracing_(false)
105✔
58
{
59
}
105✔
60

61
MockSupport::~MockSupport()
182✔
62
{
63
}
182✔
64

65
void MockSupport::crashOnFailure(bool shouldCrash)
4✔
66
{
67
    activeReporter_->crashOnFailure(shouldCrash);
4✔
68
}
4✔
69

70
void MockSupport::setMockFailureStandardReporter(MockFailureReporter* reporter)
1,289✔
71
{
72
    standardReporter_ = (reporter != NULLPTR) ? reporter : &defaultReporter_;
1,289✔
73

74
    if (lastActualFunctionCall_)
1,289✔
75
        lastActualFunctionCall_->setMockFailureReporter(standardReporter_);
42✔
76

77
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
1,299✔
78
        if (getMockSupport(p)) getMockSupport(p)->setMockFailureStandardReporter(standardReporter_);
10✔
79
}
1,289✔
80

81
void MockSupport::setActiveReporter(MockFailureReporter* reporter)
5,337✔
82
{
83
    activeReporter_ = (reporter) ? reporter : standardReporter_;
5,337✔
84
}
5,337✔
85

86
void MockSupport::setDefaultComparatorsAndCopiersRepository()
5,337✔
87
{
88
    MockNamedValue::setDefaultComparatorsAndCopiersRepository(&comparatorsAndCopiersRepository_);
5,337✔
89
}
5,337✔
90

91
void MockSupport::installComparator(const SimpleString& typeName, MockNamedValueComparator& comparator)
29✔
92
{
93
    comparatorsAndCopiersRepository_.installComparator(typeName, comparator);
29✔
94

95
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
30✔
96
        if (getMockSupport(p)) getMockSupport(p)->installComparator(typeName, comparator);
1✔
97
}
29✔
98

99
void MockSupport::installCopier(const SimpleString& typeName, MockNamedValueCopier& copier)
19✔
100
{
101
    comparatorsAndCopiersRepository_.installCopier(typeName, copier);
19✔
102

103
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
20✔
104
        if (getMockSupport(p)) getMockSupport(p)->installCopier(typeName, copier);
1✔
105
}
19✔
106

107
void MockSupport::installComparatorsAndCopiers(const MockNamedValueComparatorsAndCopiersRepository& repository)
602✔
108
{
109
    comparatorsAndCopiersRepository_.installComparatorsAndCopiers(repository);
602✔
110

111
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
603✔
112
        if (getMockSupport(p)) getMockSupport(p)->installComparatorsAndCopiers(repository);
1✔
113
}
602✔
114

115
void MockSupport::removeAllComparatorsAndCopiers()
588✔
116
{
117
    comparatorsAndCopiersRepository_.clear();
588✔
118
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
594✔
119
        if (getMockSupport(p)) getMockSupport(p)->removeAllComparatorsAndCopiers();
6✔
120
}
588✔
121

122
void MockSupport::clear()
975✔
123
{
124
    delete lastActualFunctionCall_;
975✔
125
    lastActualFunctionCall_ = NULLPTR;
975✔
126

127
    tracing_ = false;
975✔
128
    MockActualCallTrace::clearInstance();
975✔
129

130
    expectations_.deleteAllExpectationsAndClearList();
975✔
131
    ignoreOtherCalls_ = false;
975✔
132
    enabled_ = true;
975✔
133
    actualCallOrder_ = 0;
975✔
134
    expectedCallOrder_ = 0;
975✔
135
    strictOrdering_ = false;
975✔
136

137
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) {
1,087✔
138
        MockSupport* support = getMockSupport(p);
112✔
139
        if (support) {
112✔
140
            support->clear();
77✔
141
            delete support;
77✔
142
        }
143
    }
144
    data_.clear();
975✔
145
}
975✔
146

147
void MockSupport::strictOrder()
20✔
148
{
149
    strictOrdering_ = true;
20✔
150
}
20✔
151

152
SimpleString MockSupport::appendScopeToName(const SimpleString& functionName)
876✔
153
{
154
    if (mockName_.isEmpty()) return functionName;
876✔
155
    return mockName_ + "::" + functionName;
146✔
156
}
157

158
MockExpectedCall& MockSupport::expectOneCall(const SimpleString& functionName)
386✔
159
{
160
    return expectNCalls(1, functionName);
386✔
161
}
162

163
void MockSupport::expectNoCall(const SimpleString& functionName)
10✔
164
{
165
    expectNCalls(0, functionName);
10✔
166
}
10✔
167

168
MockExpectedCall& MockSupport::expectNCalls(unsigned int amount, const SimpleString& functionName)
409✔
169
{
170
    if (!enabled_) return MockIgnoredExpectedCall::instance();
409✔
171

172
    countCheck();
405✔
173

174
    MockCheckedExpectedCall* call = new MockCheckedExpectedCall(amount);
405✔
175
    call->withName(appendScopeToName(functionName));
405✔
176
    if (strictOrdering_) {
405✔
177
        call->withCallOrder(expectedCallOrder_ + 1, expectedCallOrder_ + amount);
29✔
178
        expectedCallOrder_ += amount;
29✔
179
    }
180
    expectations_.addExpectedCall(call);
405✔
181
    return *call;
405✔
182
}
183

184
MockCheckedActualCall* MockSupport::createActualCall()
411✔
185
{
186
    lastActualFunctionCall_ = new MockCheckedActualCall(++actualCallOrder_, activeReporter_, expectations_);
411✔
187
    return lastActualFunctionCall_;
411✔
188
}
189

190
bool MockSupport::callIsIgnored(const SimpleString& functionName)
446✔
191
{
192
    return ignoreOtherCalls_ && !expectations_.hasExpectationWithName(functionName);
446✔
193
}
194

195
MockActualCall& MockSupport::actualCall(const SimpleString& functionName)
471✔
196
{
197
    const SimpleString scopeFunctionName = appendScopeToName(functionName);
471✔
198

199
    if (lastActualFunctionCall_) {
471✔
200
        lastActualFunctionCall_->checkExpectations();
124✔
201
        delete lastActualFunctionCall_;
124✔
202
        lastActualFunctionCall_ = NULLPTR;
124✔
203
    }
204

205
    if (!enabled_) return MockIgnoredActualCall::instance();
471✔
206
    if (tracing_) return MockActualCallTrace::instance().withName(scopeFunctionName);
452✔
207

208

209
    if (callIsIgnored(scopeFunctionName)) {
446✔
210
        return MockIgnoredActualCall::instance();
35✔
211
    }
212

213
    MockCheckedActualCall* call = createActualCall();
411✔
214
    call->withName(scopeFunctionName);
411✔
215
    return *call;
401✔
216
}
466✔
217

218
void MockSupport::ignoreOtherCalls()
22✔
219
{
220
    ignoreOtherCalls_ = true;
22✔
221

222
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
24✔
223
        if (getMockSupport(p)) getMockSupport(p)->ignoreOtherCalls();
2✔
224
}
22✔
225

226
void MockSupport::disable()
23✔
227
{
228
    enabled_ = false;
23✔
229

230
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
24✔
231
        if (getMockSupport(p)) getMockSupport(p)->disable();
1✔
232
}
23✔
233

234
void MockSupport::enable()
23✔
235
{
236
    enabled_ = true;
23✔
237

238
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
25✔
239
        if (getMockSupport(p)) getMockSupport(p)->enable();
2✔
240
}
23✔
241

242
void MockSupport::tracing(bool enabled)
83✔
243
{
244
    tracing_ = enabled;
83✔
245

246
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
84✔
247
        if (getMockSupport(p)) getMockSupport(p)->tracing(enabled);
1✔
248
}
83✔
249

250
const char* MockSupport::getTraceOutput()
6✔
251
{
252
    return MockActualCallTrace::instance().getTraceOutput();
6✔
253
}
254

255
bool MockSupport::expectedCallsLeft()
871✔
256
{
257
    checkExpectationsOfLastActualCall();
871✔
258
    int callsLeft = expectations_.hasUnfulfilledExpectations();
871✔
259

260
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
909✔
261
        if (getMockSupport(p)) callsLeft += getMockSupport(p)->expectedCallsLeft();
38✔
262

263
    return callsLeft != 0;
871✔
264
}
265

266
bool MockSupport::wasLastActualCallFulfilled()
896✔
267
{
268
    if (lastActualFunctionCall_ && !lastActualFunctionCall_->isFulfilled())
896✔
269
        return false;
44✔
270

271
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
890✔
272
        if (getMockSupport(p) && !getMockSupport(p)->wasLastActualCallFulfilled())
44✔
273
                return false;
6✔
274

275
    return true;
846✔
276
}
277

278
void MockSupport::failTestWithExpectedCallsNotFulfilled()
11✔
279
{
280
    MockExpectedCallsList expectationsList;
11✔
281
    expectationsList.addExpectations(expectations_);
11✔
282

283
    for(MockNamedValueListNode *p = data_.begin();p;p = p->next())
14✔
284
        if(getMockSupport(p))
3✔
285
            expectationsList.addExpectations(getMockSupport(p)->expectations_);
3✔
286

287
    MockExpectedCallsDidntHappenFailure failure(activeReporter_->getTestToFail(), expectationsList);
11✔
288
    failTest(failure);
11✔
289
}
11✔
290

291
void MockSupport::failTestWithOutOfOrderCalls()
5✔
292
{
293
    MockExpectedCallsList expectationsList;
5✔
294
    expectationsList.addExpectations(expectations_);
5✔
295

296
    for(MockNamedValueListNode *p = data_.begin();p;p = p->next())
10✔
297
        if(getMockSupport(p))
5✔
298
            expectationsList.addExpectations(getMockSupport(p)->expectations_);
5✔
299

300
    MockCallOrderFailure failure(activeReporter_->getTestToFail(), expectationsList);
5✔
301
    failTest(failure);
5✔
302
}
5✔
303

304
void MockSupport::failTest(MockFailure& failure)
16✔
305
{
306
    clear();
16✔
307
    activeReporter_->failTest(failure);
16✔
308
}
16✔
309

310
void MockSupport::countCheck()
405✔
311
{
312
    UtestShell::getCurrent()->countCheck();
405✔
313
}
405✔
314

315
void MockSupport::checkExpectationsOfLastActualCall()
1,737✔
316
{
317
    if(lastActualFunctionCall_)
1,737✔
318
        lastActualFunctionCall_->checkExpectations();
521✔
319

320
    for(MockNamedValueListNode *p = data_.begin();p;p = p->next())
1,820✔
321
        if(getMockSupport(p) && getMockSupport(p)->lastActualFunctionCall_)
83✔
322
            getMockSupport(p)->lastActualFunctionCall_->checkExpectations();
32✔
323
}
1,737✔
324

325
bool MockSupport::hasCallsOutOfOrder()
894✔
326
{
327
    if (expectations_.hasCallsOutOfOrder())
894✔
328
    {
329
        return true;
5✔
330
    }
331
    for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
928✔
332
        if (getMockSupport(p) && getMockSupport(p)->hasCallsOutOfOrder())
42✔
333
        {
334
            return true;
3✔
335
        }
336
    return false;
886✔
337
}
338

339
void MockSupport::checkExpectations()
866✔
340
{
341
    checkExpectationsOfLastActualCall();
866✔
342

343
    if (wasLastActualCallFulfilled() && expectedCallsLeft())
866✔
344
        failTestWithExpectedCallsNotFulfilled();
11✔
345

346
    if (hasCallsOutOfOrder())
866✔
347
        failTestWithOutOfOrderCalls();
5✔
348
}
866✔
349

350

351
bool MockSupport::hasData(const SimpleString& name)
240✔
352
{
353
    return data_.getValueByName(name) != NULLPTR;
240✔
354
}
355

356
MockNamedValue* MockSupport::retrieveDataFromStore(const SimpleString& name)
117✔
357
{
358
    MockNamedValue* newData = data_.getValueByName(name);
117✔
359
    if (newData == NULLPTR) {
117✔
360
        newData = new MockNamedValue(name);
112✔
361
        data_.add(newData);
112✔
362
    }
363
    return newData;
117✔
364
}
365

366
void MockSupport::setData(const SimpleString& name, bool value)
3✔
367
{
368
    MockNamedValue* newData = retrieveDataFromStore(name);
3✔
369
    newData->setValue(value);
3✔
370
}
3✔
371

372
void MockSupport::setData(const SimpleString& name, unsigned int value)
2✔
373
{
374
    MockNamedValue* newData = retrieveDataFromStore(name);
2✔
375
    newData->setValue(value);
2✔
376
}
2✔
377

378
void MockSupport::setData(const SimpleString& name, int value)
9✔
379
{
380
    MockNamedValue* newData = retrieveDataFromStore(name);
9✔
381
    newData->setValue(value);
9✔
382
}
9✔
383

NEW
384
void MockSupport::setData(const SimpleString& name, long int value)
×
385
{
NEW
386
    MockNamedValue* newData = retrieveDataFromStore(name);
×
NEW
387
    newData->setValue(value);
×
NEW
388
}
×
389

NEW
390
void MockSupport::setData(const SimpleString& name, unsigned long int value)
×
391
{
NEW
392
    MockNamedValue* newData = retrieveDataFromStore(name);
×
NEW
393
    newData->setValue(value);
×
NEW
394
}
×
395

396
void MockSupport::setData(const SimpleString& name, const char* value)
4✔
397
{
398
    MockNamedValue* newData = retrieveDataFromStore(name);
4✔
399
    newData->setValue(value);
4✔
400
}
4✔
401

402
void MockSupport::setData(const SimpleString& name, double value)
4✔
403
{
404
    MockNamedValue* newData = retrieveDataFromStore(name);
4✔
405
    newData->setValue(value);
4✔
406
}
4✔
407

408
void MockSupport::setData(const SimpleString& name, void* value)
4✔
409
{
410
    MockNamedValue* newData = retrieveDataFromStore(name);
4✔
411
    newData->setValue(value);
4✔
412
}
4✔
413

414
void MockSupport::setData(const SimpleString& name, const void* value)
4✔
415
{
416
    MockNamedValue* newData = retrieveDataFromStore(name);
4✔
417
    newData->setValue(value);
4✔
418
}
4✔
419

420
void MockSupport::setData(const SimpleString& name, void (*value)())
4✔
421
{
422
    MockNamedValue* newData = retrieveDataFromStore(name);
4✔
423
    newData->setValue(value);
4✔
424
}
4✔
425

426
void MockSupport::setDataObject(const SimpleString& name, const SimpleString& type, void* value)
81✔
427
{
428
    MockNamedValue* newData = retrieveDataFromStore(name);
81✔
429
    newData->setObjectPointer(type, value);
81✔
430
}
81✔
431

432
void MockSupport::setDataConstObject(const SimpleString& name, const SimpleString& type, const void* value)
2✔
433
{
434
    MockNamedValue* newData = retrieveDataFromStore(name);
2✔
435
    newData->setConstObjectPointer(type, value);
2✔
436
}
2✔
437

438
MockNamedValue MockSupport::getData(const SimpleString& name)
356✔
439
{
440
    MockNamedValue* value = data_.getValueByName(name);
356✔
441
    if (value == NULLPTR)
356✔
442
        return MockNamedValue("");
2✔
443
    return *value;
354✔
444
}
445

446
MockSupport* MockSupport::clone(const SimpleString& mockName)
77✔
447
{
448
    MockSupport* newMock = new MockSupport(mockName);
77✔
449
    newMock->setMockFailureStandardReporter(standardReporter_);
77✔
450
    if (ignoreOtherCalls_) newMock->ignoreOtherCalls();
77✔
451

452
    if (!enabled_) newMock->disable();
77✔
453

454
    if (strictOrdering_) newMock->strictOrder();
77✔
455

456
    newMock->tracing(tracing_);
77✔
457
    newMock->installComparatorsAndCopiers(comparatorsAndCopiersRepository_);
77✔
458
    return newMock;
77✔
459
}
460

461
MockSupport* MockSupport::getMockSupportScope(const SimpleString& name)
237✔
462
{
463
    SimpleString mockingSupportName = MOCK_SUPPORT_SCOPE_PREFIX;
237✔
464
    mockingSupportName += name;
237✔
465

466
    if (hasData(mockingSupportName)) {
237✔
467
        STRCMP_EQUAL("MockSupport", getData(mockingSupportName).getType().asCharString());
160✔
468
        return (MockSupport*) getData(mockingSupportName).getObjectPointer();
160✔
469
    }
470

471
    MockSupport *newMock = clone(name);
77✔
472

473
    setDataObject(mockingSupportName, "MockSupport", newMock);
77✔
474
    return newMock;
77✔
475
}
237✔
476

477
MockSupport* MockSupport::getMockSupport(MockNamedValueListNode* node)
554✔
478
{
479
    if (node->getType() == "MockSupport" && node->getName().contains(MOCK_SUPPORT_SCOPE_PREFIX))
554✔
480
        return (MockSupport*) node->item()->getObjectPointer();
449✔
481
    return NULLPTR;
105✔
482
}
483

484
MockNamedValue MockSupport::returnValue()
60✔
485
{
486
    if (lastActualFunctionCall_) return lastActualFunctionCall_->returnValue();
60✔
487
    return MockNamedValue("");
1✔
488
}
489

490
bool MockSupport::boolReturnValue()
2✔
491
{
492
    return returnValue().getBoolValue();
2✔
493
}
494

495
unsigned int MockSupport::unsignedIntReturnValue()
2✔
496
{
497
    return returnValue().getUnsignedIntValue();
2✔
498
}
499

500
int MockSupport::intReturnValue()
2✔
501
{
502
    return returnValue().getIntValue();
2✔
503
}
504

505
const char * MockSupport::returnStringValueOrDefault(const char * defaultValue)
2✔
506
{
507
    if (hasReturnValue()) {
2✔
508
        return stringReturnValue();
1✔
509
    }
510
    return defaultValue;
1✔
511
}
512

513
double MockSupport::returnDoubleValueOrDefault(double defaultValue)
2✔
514
{
515
    if (hasReturnValue()) {
2✔
516
        return doubleReturnValue();
1✔
517
    }
518
    return defaultValue;
1✔
519
}
520

521
long int MockSupport::returnLongIntValueOrDefault(long int defaultValue)
2✔
522
{
523
    if (hasReturnValue()) {
2✔
524
        return longIntReturnValue();
1✔
525
    }
526
    return defaultValue;
1✔
527
}
528

529
bool MockSupport::returnBoolValueOrDefault(bool defaultValue)
2✔
530
{
531
    if (hasReturnValue()) {
2✔
532
        return boolReturnValue();
1✔
533
    }
534
    return defaultValue;
1✔
535
}
536

537
int MockSupport::returnIntValueOrDefault(int defaultValue)
2✔
538
{
539
    if (hasReturnValue()) {
2✔
540
        return intReturnValue();
1✔
541
    }
542
    return defaultValue;
1✔
543
}
544

545
unsigned int MockSupport::returnUnsignedIntValueOrDefault(unsigned int defaultValue)
2✔
546
{
547
    if (hasReturnValue()) {
2✔
548
        return unsignedIntReturnValue();
1✔
549
    }
550
    return defaultValue;
1✔
551
}
552

553
unsigned long int MockSupport::returnUnsignedLongIntValueOrDefault(unsigned long int defaultValue)
2✔
554
{
555
    if (hasReturnValue()) {
2✔
556
        return unsignedLongIntReturnValue();
1✔
557
    }
558
    return defaultValue;
1✔
559
}
560

561
long int MockSupport::longIntReturnValue()
2✔
562
{
563
    return returnValue().getLongIntValue();
2✔
564
}
565

566
unsigned long int MockSupport::unsignedLongIntReturnValue()
2✔
567
{
568
    return returnValue().getUnsignedLongIntValue();
2✔
569
}
570

571
#if CPPUTEST_USE_LONG_LONG
572

573
cpputest_longlong MockSupport::longLongIntReturnValue()
2✔
574
{
575
    return returnValue().getLongLongIntValue();
2✔
576
}
577

578
cpputest_ulonglong MockSupport::unsignedLongLongIntReturnValue()
2✔
579
{
580
    return returnValue().getUnsignedLongLongIntValue();
2✔
581
}
582

583
cpputest_longlong MockSupport::returnLongLongIntValueOrDefault(cpputest_longlong defaultValue)
2✔
584
{
585
    if (hasReturnValue()) {
2✔
586
        return longLongIntReturnValue();
1✔
587
    }
588
    return defaultValue;
1✔
589
}
590

591
cpputest_ulonglong MockSupport::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong defaultValue)
2✔
592
{
593
    if (hasReturnValue()) {
2✔
594
        return unsignedLongLongIntReturnValue();
1✔
595
    }
596
    return defaultValue;
1✔
597
}
598

599
#else
600

601
cpputest_longlong MockSupport::longLongIntReturnValue()
602
{
603
    FAIL("Long Long type is not supported");
604
    cpputest_longlong ret = {};
605
    return ret;
606
}
607

608
cpputest_ulonglong MockSupport::unsignedLongLongIntReturnValue()
609
{
610
    FAIL("Unsigned Long Long type is not supported");
611
    cpputest_ulonglong ret = {};
612
    return ret;
613
}
614

615
cpputest_longlong MockSupport::returnLongLongIntValueOrDefault(cpputest_longlong defaultValue)
616
{
617
    FAIL("Long Long type is not supported");
618
    return defaultValue;
619
}
620

621
cpputest_ulonglong MockSupport::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong defaultValue)
622
{
623
    FAIL("Unsigned Long Long type is not supported");
624
    return defaultValue;
625
}
626

627
#endif
628

629
const char* MockSupport::stringReturnValue()
2✔
630
{
631
    return returnValue().getStringValue();
2✔
632
}
633

634
double MockSupport::doubleReturnValue()
2✔
635
{
636
    return returnValue().getDoubleValue();
2✔
637
}
638

639
void * MockSupport::returnPointerValueOrDefault(void * defaultValue)
2✔
640
{
641
    if (hasReturnValue()) {
2✔
642
        return pointerReturnValue();
1✔
643
    }
644
    return defaultValue;
1✔
645
}
646

647
const void* MockSupport::returnConstPointerValueOrDefault(const void * defaultValue)
2✔
648
{
649
    if (hasReturnValue()) {
2✔
650
        return constPointerReturnValue();
1✔
651
    }
652
    return defaultValue;
1✔
653
}
654

655
void (*MockSupport::returnFunctionPointerValueOrDefault(void (*defaultValue)()))()
2✔
656
{
657
    if (hasReturnValue()) {
2✔
658
        return functionPointerReturnValue();
1✔
659
    }
660
    return defaultValue;
1✔
661
}
662

663
void* MockSupport::pointerReturnValue()
2✔
664
{
665
    return returnValue().getPointerValue();
2✔
666
}
667

668
const void* MockSupport::constPointerReturnValue()
2✔
669
{
670
    return returnValue().getConstPointerValue();
2✔
671
}
672

673
void (*MockSupport::functionPointerReturnValue())()
2✔
674
{
675
    return returnValue().getFunctionPointerValue();
2✔
676
}
677

678
bool MockSupport::hasReturnValue()
94✔
679
{
680
    if (lastActualFunctionCall_) return lastActualFunctionCall_->hasReturnValue();
94✔
681
    return false;
15✔
682
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc