Skip to content

Improve performance of MockExpectedCallsList #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed macro naming and using <assert.h>
  • Loading branch information
mmartalo committed Aug 23, 2015
commit a00b036fc262265b3a0d59a90f60e1db1da3b3ca
22 changes: 11 additions & 11 deletions src/CppUTestExt/MockExpectedCallsList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockExpectedCallsList.h"
#include "CppUTestExt/MockCheckedExpectedCall.h"
#include <cassert>
#include <assert.h>

MockExpectedCallsList::MockExpectedCallsList() : head_(NULL), tail_(NULL)
{
Expand Down Expand Up @@ -147,7 +147,7 @@ void MockExpectedCallsList::addExpectations(const MockExpectedCallsList& list)
// of pruneEmptyNodeFromList(), and letting the "parent = p" execute normally in the for loop).
//
// You need to close the curly bracket after the processing step.
#define ITERATE_WITH_PREV_AND_NEXT \
#define ITERATE_WITH_PARENT_AND_NEXT \
for (MockExpectedCallsListNode* p = head_, *parent = NULL, *next; p; parent = p, p = next) {\
next = p->next_;

Expand All @@ -174,7 +174,7 @@ void MockExpectedCallsList::pruneEmptyNodeFromList(MockExpectedCallsListNode*& p

void MockExpectedCallsList::onlyKeepExpectationsRelatedTo(const SimpleString& name)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->relatesTo(name)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -184,7 +184,7 @@ void MockExpectedCallsList::onlyKeepExpectationsRelatedTo(const SimpleString& na

void MockExpectedCallsList::onlyKeepUnfulfilledExpectations()
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (p->expectedCall_->isFulfilled())
{
p->expectedCall_->resetExpectation();
Expand All @@ -196,7 +196,7 @@ void MockExpectedCallsList::onlyKeepUnfulfilledExpectations()

void MockExpectedCallsList::onlyKeepExpectationsWithInputParameterName(const SimpleString& name)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->hasInputParameterWithName(name)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -206,7 +206,7 @@ void MockExpectedCallsList::onlyKeepExpectationsWithInputParameterName(const Sim

void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameterName(const SimpleString& name)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->hasOutputParameterWithName(name)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -216,7 +216,7 @@ void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameterName(const Si

void MockExpectedCallsList::onlyKeepExpectationsWithInputParameter(const MockNamedValue& parameter)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->hasInputParameter(parameter)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -226,7 +226,7 @@ void MockExpectedCallsList::onlyKeepExpectationsWithInputParameter(const MockNam

void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameter(const MockNamedValue& parameter)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->hasOutputParameter(parameter)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -236,7 +236,7 @@ void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameter(const MockNa

void MockExpectedCallsList::onlyKeepExpectationsOnObject(void* objectPtr)
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (! p->expectedCall_->relatesToObject(objectPtr)) {
p->expectedCall_ = NULL;
pruneEmptyNodeFromList(parent, p);
Expand All @@ -246,7 +246,7 @@ void MockExpectedCallsList::onlyKeepExpectationsOnObject(void* objectPtr)

MockCheckedExpectedCall* MockExpectedCallsList::removeOneFulfilledExpectation()
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (p->expectedCall_->isFulfilled()) {
MockCheckedExpectedCall* fulfilledCall = p->expectedCall_;
p->expectedCall_ = NULL;
Expand All @@ -269,7 +269,7 @@ MockCheckedExpectedCall* MockExpectedCallsList::getOneFulfilledExpectationWithIg

MockCheckedExpectedCall* MockExpectedCallsList::removeOneFulfilledExpectationWithIgnoredParameters()
{
ITERATE_WITH_PREV_AND_NEXT
ITERATE_WITH_PARENT_AND_NEXT
if (p->expectedCall_->isFulfilledWithoutIgnoredParameters()) {
MockCheckedExpectedCall* fulfilledCall = p->expectedCall_;
p->expectedCall_->parametersWereIgnored();
Expand Down