diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2016-09-22 04:42:23 -0700 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2016-09-26 12:58:27 +0200 |
commit | a6dd353c6a1cc65c016b1bd1e4cf39fd6b13a837 (patch) | |
tree | dd0c1b65b184a8e21b3ee57a8bc9a5c00821af19 | |
parent | b6f6f61bce3a2f5cac51be1b435566a81754fb2d (diff) |
ClientTest: avoid pass-by-value
The CreateSource instance can be big, so passing by reference definitely
is better. Found with cppcheck.
-rw-r--r-- | test/ClientTest.cpp | 22 | ||||
-rw-r--r-- | test/ClientTest.h | 18 |
2 files changed, 20 insertions, 20 deletions
diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 10434e5e..0bf604d9 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -657,7 +657,7 @@ void LocalTests::addTests() { } } -std::string LocalTests::insert(CreateSource createSource, const std::string &data, bool relaxed, std::string *inserted, const std::string &uniqueUIDSuffix) { +std::string LocalTests::insert(const CreateSource &createSource, const std::string &data, bool relaxed, std::string *inserted, const std::string &uniqueUIDSuffix) { restoreStorage(config, client); // create source @@ -705,7 +705,7 @@ std::string LocalTests::insert(CreateSource createSource, const std::string &dat } /** deletes specific item locally via sync source */ -static std::string updateItem(CreateSource createSource, const ClientTestConfig &config, const std::string &uid, const std::string &data, std::string *updated = NULL) { +static std::string updateItem(const CreateSource &createSource, const ClientTestConfig &config, const std::string &uid, const std::string &data, std::string *updated = NULL) { std::string newuid; CT_ASSERT(createSource.createSource); @@ -728,7 +728,7 @@ static std::string updateItem(CreateSource createSource, const ClientTestConfig } /** updates specific item locally via sync source */ -static void removeItem(CreateSource createSource, const std::string &luid) +static void removeItem(const CreateSource &createSource, const std::string &luid) { CT_ASSERT(createSource.createSource); @@ -740,7 +740,7 @@ static void removeItem(CreateSource createSource, const std::string &luid) SOURCE_ASSERT_NO_FAILURE(source.get(), source->deleteItem(luid)); } -void LocalTests::update(CreateSource createSource, const std::string &data, bool check, const std::string &uniqueUIDSuffix) { +void LocalTests::update(const CreateSource &createSource, const std::string &data, bool check, const std::string &uniqueUIDSuffix) { CT_ASSERT(createSource.createSource); restoreStorage(config, client); @@ -779,7 +779,7 @@ void LocalTests::update(CreateSource createSource, const std::string &data, bool backupStorage(config, client); } -void LocalTests::update(CreateSource createSource, const std::string &data, const std::string &luid) { +void LocalTests::update(const CreateSource &createSource, const std::string &data, const std::string &luid) { CT_ASSERT(createSource.createSource); restoreStorage(config, client); @@ -794,7 +794,7 @@ void LocalTests::update(CreateSource createSource, const std::string &data, cons } /** deletes all items locally via sync source */ -void LocalTests::deleteAll(CreateSource createSource) { +void LocalTests::deleteAll(const CreateSource &createSource) { CT_ASSERT(createSource.createSource); restoreStorage(config, client); @@ -819,7 +819,7 @@ void LocalTests::deleteAll(CreateSource createSource) { } /** deletes specific item locally via sync source */ -static void deleteItem(CreateSource createSource, const std::string &uid) { +static void deleteItem(const CreateSource &createSource, const std::string &uid) { CT_ASSERT(createSource.createSource); // create source @@ -995,7 +995,7 @@ std::string LocalTests::createItem(int item, const std::string &revision, int si * @param size minimum size for new items * @return LUIDs of all inserted items */ -std::list<std::string> LocalTests::insertManyItems(CreateSource createSource, int startIndex, int numItems, int size) { +std::list<std::string> LocalTests::insertManyItems(const CreateSource &createSource, int startIndex, int numItems, int size) { std::list<std::string> luids; CT_ASSERT(!config.m_templateItem.empty()); @@ -1038,7 +1038,7 @@ std::list<std::string> LocalTests::insertManyItems(TestingSyncSource *source, in return luids; } -void LocalTests::updateManyItems(CreateSource createSource, int startIndex, int numItems, int size, +void LocalTests::updateManyItems(const CreateSource &createSource, int startIndex, int numItems, int size, int revision, std::list<std::string> &luids, int offset) @@ -1066,7 +1066,7 @@ void LocalTests::updateManyItems(CreateSource createSource, int startIndex, int backupStorage(config, client); } -void LocalTests::removeManyItems(CreateSource createSource, int numItems, +void LocalTests::removeManyItems(const CreateSource &createSource, int numItems, std::list<std::string> &luids, int offset) { @@ -1085,7 +1085,7 @@ void LocalTests::removeManyItems(CreateSource createSource, int numItems, } // update every single item in the database -void LocalTests::updateData(CreateSource createSource) { +void LocalTests::updateData(const CreateSource &createSource) { // check additional requirements CT_ASSERT(config.m_update); diff --git a/test/ClientTest.h b/test/ClientTest.h index 1933929f..49b3a59d 100644 --- a/test/ClientTest.h +++ b/test/ClientTest.h @@ -450,7 +450,7 @@ public: source(sourceParam), isSourceA(isSourceAParam) {} - TestingSyncSource *operator() () { + TestingSyncSource *operator() () const { CPPUNIT_ASSERT(createSource); return createSource(client, client.getClientID(), source, isSourceA); } @@ -521,7 +521,7 @@ public: * @param uniqueUIDSuffix gets added to UID of the inserted item if unique UIDs are necessary * @return the LUID of the inserted item */ - virtual std::string insert(CreateSource createSource, const std::string &data, bool relaxed = false, std::string *inserted = NULL, const std::string &uniqueUIDSuffix = ""); + virtual std::string insert(const CreateSource &createSource, const std::string &data, bool relaxed = false, std::string *inserted = NULL, const std::string &uniqueUIDSuffix = ""); /** * assumes that exactly one element is currently inserted and updates it with the given item @@ -529,17 +529,17 @@ public: * @param check if true, then reopen the source and verify that the reported items are as expected * @param uniqueUIDSuffix same UID suffix as when creating the item */ - virtual void update(CreateSource createSource, const std::string &data, bool check = true, const std::string &uniqueUIDSuffix = ""); + virtual void update(const CreateSource &createSource, const std::string &data, bool check = true, const std::string &uniqueUIDSuffix = ""); /** * updates one item identified by its LUID with the given item * * The type of the item is cleared, as in insert() above. */ - virtual void update(CreateSource createSource, const std::string &data, const std::string &luid); + virtual void update(const CreateSource &createSource, const std::string &data, const std::string &luid); /** deletes all items locally via sync source */ - virtual void deleteAll(CreateSource createSource); + virtual void deleteAll(const CreateSource &createSource); /** * takes two databases, exports them, @@ -583,7 +583,7 @@ public: * @param size minimum size for new items * @return number of items inserted */ - virtual std::list<std::string> insertManyItems(CreateSource createSource, int startIndex = 1, int numItems = 0, int size = -1); + virtual std::list<std::string> insertManyItems(const CreateSource &createSource, int startIndex = 1, int numItems = 0, int size = -1); virtual std::list<std::string> insertManyItems(TestingSyncSource *source, int startIndex = 1, int numItems = 0, int size = -1); /** @@ -594,7 +594,7 @@ public: * @param luids result from corresponding insertManyItems() call * @param offset skip that many items at the start of luids before updating the following ones */ - void updateManyItems(CreateSource createSource, int startIndex, int numItems, int size, + void updateManyItems(const CreateSource &createSource, int startIndex, int numItems, int size, int revision, std::list<std::string> &luids, int offset); @@ -602,14 +602,14 @@ public: /** * Delete items. Skips offset items in luids before deleting numItems. */ - void removeManyItems(CreateSource createSource, int numItems, + void removeManyItems(const CreateSource &createSource, int numItems, std::list<std::string> &luids, int offset); /** * update every single item, using config.update */ - virtual void updateData(CreateSource createSource); + virtual void updateData(const CreateSource &createSource); /** * create an artificial item for the current database |