diff --git a/tests/unittests/libretroshare/gxs/common/data_support.cc b/tests/unittests/libretroshare/gxs/common/data_support.cc index 1b64e8e8c..ce716c62a 100644 --- a/tests/unittests/libretroshare/gxs/common/data_support.cc +++ b/tests/unittests/libretroshare/gxs/common/data_support.cc @@ -151,7 +151,7 @@ void init_item(RsGxsMsgMetaData* metaMsg) -RsSerialType* init_item(RsNxsGrp& nxg) +void init_item(RsNxsGrp& nxg,RsSerialType **ser) { nxg.clear(); @@ -160,11 +160,12 @@ RsSerialType* init_item(RsNxsGrp& nxg) init_item(nxg.grp); init_item(nxg.meta); - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsMsg& nxm) +void init_item(RsNxsMsg& nxm,RsSerialType **ser) { nxm.clear(); @@ -174,20 +175,22 @@ RsSerialType* init_item(RsNxsMsg& nxm) init_item(nxm.meta); nxm.transactionNumber = rand()%23; - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsSyncGrpReqItem& rsg) +void init_item(RsNxsSyncGrpReqItem& rsg,RsSerialType **ser) { rsg.clear(); rsg.flag = RsNxsSyncGrpItem::FLAG_USE_SYNC_HASH; rsg.createdSince = rand()%2423; randString(3124,rsg.syncHash); - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsSyncMsgReqItem& rsgm) +void init_item(RsNxsSyncMsgReqItem& rsgm,RsSerialType **ser) { rsgm.clear(); @@ -197,10 +200,11 @@ RsSerialType* init_item(RsNxsSyncMsgReqItem& rsgm) init_random(rsgm.grpId) ; randString(SHORT_STR, rsgm.syncHash); - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsSyncGrpItem& rsgl) +void init_item(RsNxsSyncGrpItem& rsgl,RsSerialType **ser) { rsgl.clear(); @@ -209,10 +213,11 @@ RsSerialType* init_item(RsNxsSyncGrpItem& rsgl) rsgl.publishTs = rand()%23; init_random(rsgl.grpId) ; - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsSyncMsgItem& rsgml) +void init_item(RsNxsSyncMsgItem& rsgml,RsSerialType **ser) { rsgml.clear(); @@ -221,11 +226,12 @@ RsSerialType* init_item(RsNxsSyncMsgItem& rsgml) init_random(rsgml.grpId) ; init_random(rsgml.msgId) ; - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsNxsTransacItem &rstx){ - +void init_item(RsNxsTransacItem &rstx,RsSerialType **ser) +{ rstx.clear(); rstx.timestamp = rand()%14141; @@ -233,7 +239,8 @@ RsSerialType* init_item(RsNxsTransacItem &rstx){ rstx.nItems = rand()%33132; rstx.transactionNumber = rand()%242112; - return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + if(ser) + *ser = new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } diff --git a/tests/unittests/libretroshare/gxs/common/data_support.h b/tests/unittests/libretroshare/gxs/common/data_support.h index 0bb026820..674703488 100644 --- a/tests/unittests/libretroshare/gxs/common/data_support.h +++ b/tests/unittests/libretroshare/gxs/common/data_support.h @@ -21,13 +21,13 @@ void init_item(RsGxsGrpMetaData* metaGrp); void init_item(RsGxsMsgMetaData* metaMsg); -RsSerialType* init_item(RsNxsGrp& nxg); -RsSerialType* init_item(RsNxsMsg& nxm); -RsSerialType* init_item(RsNxsSyncGrpReqItem &rsg); -RsSerialType* init_item(RsNxsSyncMsgReqItem &rsgm); -RsSerialType* init_item(RsNxsSyncGrpItem& rsgl); -RsSerialType* init_item(RsNxsSyncMsgItem& rsgml); -RsSerialType* init_item(RsNxsTransacItem& rstx); +void init_item(RsNxsGrp& nxg ,RsSerialType ** = NULL); +void init_item(RsNxsMsg& nxm ,RsSerialType ** = NULL); +void init_item(RsNxsSyncGrpReqItem &rsg ,RsSerialType ** = NULL); +void init_item(RsNxsSyncMsgReqItem &rsgm,RsSerialType ** = NULL); +void init_item(RsNxsSyncGrpItem& rsgl ,RsSerialType ** = NULL); +void init_item(RsNxsSyncMsgItem& rsgml ,RsSerialType ** = NULL); +void init_item(RsNxsTransacItem& rstx ,RsSerialType ** = NULL); template void copy_all_but(T& ex, const std::list& s, std::list& d) diff --git a/tests/unittests/libretroshare/gxs/data_service/rsdataservice_test.cc b/tests/unittests/libretroshare/gxs/data_service/rsdataservice_test.cc index 9720c1294..5874c303f 100644 --- a/tests/unittests/libretroshare/gxs/data_service/rsdataservice_test.cc +++ b/tests/unittests/libretroshare/gxs/data_service/rsdataservice_test.cc @@ -5,6 +5,7 @@ #include "libretroshare/gxs/common/data_support.h" #include "rsdataservice_test.h" #include "gxs/rsgds.h" +#include "gxs/rsgxsutil.h" #include "gxs/rsdataservice.h" #define DATA_BASE_NAME "msg_grp_Store" @@ -221,7 +222,8 @@ void test_messageStoresAndRetrieve() // first selective retrieval GxsMsgResult msgResult; - GxsMsgMetaResult msgMetaResult; + + RsGxsMetaDataTemporaryMapVector msgMetaResult ; dStore->retrieveNxsMsgs(req, msgResult, false); dStore->retrieveGxsMsgMetaData(req, msgMetaResult); diff --git a/tests/unittests/libretroshare/serialiser/rsgxsiditem_test.cc b/tests/unittests/libretroshare/serialiser/rsgxsiditem_test.cc index e1488441f..c1aaa0fc0 100644 --- a/tests/unittests/libretroshare/serialiser/rsgxsiditem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsgxsiditem_test.cc @@ -38,11 +38,9 @@ bool operator==(const RsGxsIdGroupItem& it1,const RsGxsIdGroupItem& it2) return true ; } -RsSerialType* init_item(RsGxsIdGroupItem& item) +void init_item(RsGxsIdGroupItem& item) { item.mPgpIdSign = "hello"; - - return new RsGxsIdSerialiser(); } @@ -50,7 +48,7 @@ TEST(libretroshare_serialiser, RsGxsIdItem) { for(uint32_t i=0;i<20;++i) { - test_RsItem< RsGxsIdGroupItem >(); + test_RsItem< RsGxsIdGroupItem,RsGxsIdSerialiser >(); } } diff --git a/tests/unittests/libretroshare/serialiser/rsgxsupdateitem_test.cc b/tests/unittests/libretroshare/serialiser/rsgxsupdateitem_test.cc index ccaeead96..9ece9edce 100644 --- a/tests/unittests/libretroshare/serialiser/rsgxsupdateitem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsgxsupdateitem_test.cc @@ -11,15 +11,14 @@ #include "rsitems/rsgxsupdateitems.h" #define RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM 0x0010 -RsSerialType* init_item(RsGxsGrpUpdateItem& i) +void init_item(RsGxsGrpUpdateItem& i) { i.clear(); i.grpUpdateTS = rand()%2424; i.peerID = RsPeerId::random(); - return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsGxsMsgUpdateItem& i) +void init_item(RsGxsMsgUpdateItem& i) { i.clear(); i.peerID = RsPeerId::random(); @@ -33,24 +32,19 @@ RsSerialType* init_item(RsGxsMsgUpdateItem& i) info.time_stamp = rand()%45; i.msgUpdateInfos[RsGxsGroupId::random()] = info; } - - return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsGxsServerGrpUpdateItem& i) +void init_item(RsGxsServerGrpUpdateItem& i) { i.clear(); i.grpUpdateTS = rand()%2424; - - return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } -RsSerialType* init_item(RsGxsServerMsgUpdateItem& i) +void init_item(RsGxsServerMsgUpdateItem& i) { i.clear(); i.grpId = RsGxsGroupId::random(); i.msgUpdateTS = rand()%4252; - return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } bool operator ==(const RsGxsGrpUpdateItem& l, const RsGxsGrpUpdateItem& r) @@ -105,8 +99,8 @@ bool operator ==(const RsGxsServerMsgUpdateItem& l, TEST(libretroshare_serialiser, RsGxsGrpUpateItem) { - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } diff --git a/tests/unittests/libretroshare/serialiser/rsmsgitem_test.cc b/tests/unittests/libretroshare/serialiser/rsmsgitem_test.cc index 1d7d1258c..a2b1369ad 100644 --- a/tests/unittests/libretroshare/serialiser/rsmsgitem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsmsgitem_test.cc @@ -33,19 +33,16 @@ #include "rstlvutil.h" -RsSerialType* init_item(RsChatMsgItem& cmi) +void init_item(RsChatMsgItem& cmi) { cmi.chatFlags = rand()%34; cmi.sendTime = rand()%422224; randString(LARGE_STR, cmi.message); - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsChatLobbyListRequestItem& ) +void init_item(RsChatLobbyListRequestItem& ) { - return new RsChatSerialiser(); } -RsSerialType* init_item(RsChatLobbyListItem& cmi) +void init_item(RsChatLobbyListItem& cmi) { int n = rand()%20 ; @@ -59,41 +56,33 @@ RsSerialType* init_item(RsChatLobbyListItem& cmi) info.flags = ChatLobbyFlags(RSRandom::random_u32()%3) ; cmi.lobbies.push_back(info); } - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsChatLobbyMsgItem& cmi) +void init_item(RsChatLobbyMsgItem& cmi) { - RsSerialType *serial = init_item( *dynamic_cast(&cmi)) ; + init_item( *dynamic_cast(&cmi)) ; cmi.msg_id = RSRandom::random_u64() ; cmi.lobby_id = RSRandom::random_u64() ; cmi.nick = "My nickname" ; cmi.parent_msg_id = RSRandom::random_u64() ; - - return serial ; } -RsSerialType *init_item(RsChatLobbyEventItem& cmi) +void init_item(RsChatLobbyEventItem& cmi) { cmi.lobby_id = RSRandom::random_u64() ; cmi.msg_id = RSRandom::random_u64() ; randString(20, cmi.nick); cmi.event_type = RSRandom::random_u32()%256 ; randString(20, cmi.string1); - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsChatLobbyInviteItem& cmi) +void init_item(RsChatLobbyInviteItem& cmi) { cmi.lobby_id = RSRandom::random_u64() ; cmi.lobby_name = "Name of the lobby" ; cmi.lobby_topic = "Topic of the lobby" ; - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsPrivateChatMsgConfigItem& pcmi) +void init_item(RsPrivateChatMsgConfigItem& pcmi) { pcmi.configPeerId = RsPeerId::random(); pcmi.chatFlags = rand()%34; @@ -101,21 +90,17 @@ RsSerialType* init_item(RsPrivateChatMsgConfigItem& pcmi) pcmi.sendTime = rand()%422224; randString(LARGE_STR, pcmi.message); pcmi.recvTime = rand()%344443; - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsChatStatusItem& csi) +void init_item(RsChatStatusItem& csi) { randString(SHORT_STR, csi.status_string); csi.flags = rand()%232; - return new RsChatSerialiser(); - } -RsSerialType* init_item(RsChatAvatarItem& cai) +void init_item(RsChatAvatarItem& cai) { std::string image_data; randString(LARGE_STR, image_data); @@ -123,11 +108,9 @@ RsSerialType* init_item(RsChatAvatarItem& cai) memcpy(cai.image_data, image_data.c_str(), image_data.size()); cai.image_size = image_data.size(); - - return new RsChatSerialiser(); } -RsSerialType* init_item(RsMsgItem& mi) +void init_item(RsMsgItem& mi) { init_item(mi.attachment); init_item(mi.rspeerid_msgbcc); @@ -141,21 +124,17 @@ RsSerialType* init_item(RsMsgItem& mi) mi.recvTime = rand()%44252; mi.sendTime = mi.recvTime; mi.msgFlags = mi.recvTime; - - return new RsMsgSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_NONE); } -RsSerialType* init_item(RsMsgTagType& mtt) +void init_item(RsMsgTagType& mtt) { mtt.rgb_color = rand()%5353; mtt.tagId = rand()%24242; randString(SHORT_STR, mtt.text); - - return new RsMsgSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_NONE); } -RsSerialType* init_item(RsMsgTags& mt) +void init_item(RsMsgTags& mt) { mt.msgId = rand()%3334; @@ -163,24 +142,18 @@ RsSerialType* init_item(RsMsgTags& mt) for (i = 0; i < 10; i++) { mt.tagIds.push_back(rand()%21341); } - - return new RsMsgSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_NONE); } -RsSerialType* init_item(RsMsgSrcId& ms) +void init_item(RsMsgSrcId& ms) { ms.msgId = rand()%434; ms.srcId = RsPeerId::random(); - - return new RsMsgSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_NONE); } -RsSerialType* init_item(RsMsgParentId& ms) +void init_item(RsMsgParentId& ms) { ms.msgId = rand()%354; ms.msgParentId = rand()%476; - - return new RsMsgSerialiser(RsServiceSerializer::SERIALIZATION_FLAG_NONE); } bool operator ==(const struct VisibleChatLobbyInfo& l, const struct VisibleChatLobbyInfo& r) @@ -335,19 +308,19 @@ bool operator ==(const RsMsgParentId& msLeft, const RsMsgParentId& msRight) TEST(libretroshare_serialiser, RsMsgItem) { - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); } diff --git a/tests/unittests/libretroshare/serialiser/rsnxsitems_test.cc b/tests/unittests/libretroshare/serialiser/rsnxsitems_test.cc index 87bd33778..0ff8f7f44 100644 --- a/tests/unittests/libretroshare/serialiser/rsnxsitems_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsnxsitems_test.cc @@ -10,11 +10,11 @@ TEST(libretroshare_serialiser, RsNxsItem) { - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); - test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); + test_RsItem(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); } diff --git a/tests/unittests/libretroshare/serialiser/rsstatusitem_test.cc b/tests/unittests/libretroshare/serialiser/rsstatusitem_test.cc index 1f7e53f14..48d037cca 100644 --- a/tests/unittests/libretroshare/serialiser/rsstatusitem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsstatusitem_test.cc @@ -27,12 +27,11 @@ #include "support.h" #include "rsitems/rsstatusitems.h" -RsSerialType* init_item(RsStatusItem& rsi) +void init_item(RsStatusItem& rsi) { rsi.sendTime = rand()%5353; rsi.status = rand()%2032; - return new RsStatusSerialiser(); } bool operator ==(RsStatusItem& rsi1, RsStatusItem& rsi2) @@ -48,5 +47,5 @@ bool operator ==(RsStatusItem& rsi1, RsStatusItem& rsi2) TEST(libretroshare_serialiser, test_RsStatusItem) { - test_RsItem(); + test_RsItem(); } diff --git a/tests/unittests/libretroshare/serialiser/rstlvutil.cc b/tests/unittests/libretroshare/serialiser/rstlvutil.cc index 4ca2ab0e4..e468d49ad 100644 --- a/tests/unittests/libretroshare/serialiser/rstlvutil.cc +++ b/tests/unittests/libretroshare/serialiser/rstlvutil.cc @@ -172,6 +172,8 @@ int test_TlvSet(std::vector items, int maxsize) test_CreateTlvStack(std::cerr, items, data, &size); test_StepThroughTlvStack(std::cerr, data, size); + free(data) ; + return 1; } diff --git a/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc b/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc index 55a6add4b..3590d519a 100644 --- a/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc @@ -237,11 +237,12 @@ TEST(libretroshare_serialiser, RsTurtleItem) //test_RsItem(); //test_RsItem(); //test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); - test_RsItem(); + + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); + test_RsItem(); } } diff --git a/tests/unittests/libretroshare/serialiser/support.h b/tests/unittests/libretroshare/serialiser/support.h index d9d5ca48c..76ed3f359 100644 --- a/tests/unittests/libretroshare/serialiser/support.h +++ b/tests/unittests/libretroshare/serialiser/support.h @@ -100,15 +100,17 @@ bool operator==(const RsTlvKeySignatureSet& , const RsTlvKeySignatureSet& ); * @param T the item you want to test */ -template int test_RsItem() +template int test_RsItem() { /* make a serialisable RsTurtleItem */ RsSerialiser srl; /* initialise */ - T rsfi ; - RsSerialType *rsfis = init_item(rsfi) ; + ItemClass rsfi ; + RsSerialType *rsfis = new ItemSerialiser; + + init_item(rsfi); /* attempt to serialise it before we add it to the serialiser */ std::cerr << "### These errors are expected." << std::endl; @@ -149,7 +151,7 @@ template int test_RsItem() EXPECT_TRUE(sersize2 == sersize); - T *outfi = dynamic_cast(output); + ItemClass *outfi = dynamic_cast(output); EXPECT_TRUE(outfi != NULL); if (!outfi) @@ -173,22 +175,24 @@ template int test_RsItem() EXPECT_TRUE(done2) ; EXPECT_TRUE(sersize2 == sersize); + std::cerr << "Deleting output" < int test_RsItem(uint16_t servtype) +template int test_RsItem(uint16_t servtype) { /* make a serialisable RsTurtleItem */ RsSerialiser srl; /* initialise */ - T rsfi(servtype) ; - RsSerialType *rsfis = init_item(rsfi) ; // deleted on destruction of srl + ItemClass rsfi(servtype) ; + RsSerialType *rsfis = new ItemSerialiser(servtype) ; + + init_item(rsfi) ; // deleted on destruction of srl /* attempt to serialise it before we add it to the serialiser */ std::cerr << "### These errors are expected." << std::endl; @@ -223,7 +227,7 @@ template int test_RsItem(uint16_t servtype) EXPECT_TRUE(output != NULL); EXPECT_TRUE(sersize2 == sersize); - T *outfi = dynamic_cast(output); + ItemClass *outfi = dynamic_cast(output); EXPECT_TRUE(outfi != NULL); @@ -240,7 +244,6 @@ template int test_RsItem(uint16_t servtype) delete[] buffer ; delete output ; - delete rsfis ; return 1; } diff --git a/tests/unittests/libretroshare/serialiser/tlvstack_test.cc b/tests/unittests/libretroshare/serialiser/tlvstack_test.cc index d4d46ed0e..6bcfaa513 100644 --- a/tests/unittests/libretroshare/serialiser/tlvstack_test.cc +++ b/tests/unittests/libretroshare/serialiser/tlvstack_test.cc @@ -45,8 +45,8 @@ TEST(libretroshare_serialiser, test_RsTlvStack) /* now create a set of TLV items for the random generator */ - RsTlvBinaryData *bd1 = new RsTlvBinaryData(123); - RsTlvBinaryData *bd2 = new RsTlvBinaryData(125); + RsTlvBinaryData bd1(123); + RsTlvBinaryData bd2(125); char data[BIN_LEN] = {0}; int i; @@ -55,31 +55,31 @@ TEST(libretroshare_serialiser, test_RsTlvStack) data[i] = i%13; } - bd1->setBinData(data, 5); - bd2->setBinData(data, 21); + bd1.setBinData(data, 5); + bd2.setBinData(data, 21); - RsTlvFileItem *fi1 = new RsTlvFileItem(); - RsTlvFileItem *fi2 = new RsTlvFileItem(); + RsTlvFileItem fi1; + RsTlvFileItem fi2; /* initialise */ - fi1->filesize = 101010; - fi1->hash = RsFileHash("123456789ABCDEF67890123456789ABCDEF67890");//SHA1_SIZE*2 = 40 - fi1->name = "TestFile.txt"; - fi1->pop = 12; - fi1->age = 456; + fi1.filesize = 101010; + fi1.hash = RsFileHash("123456789ABCDEF67890123456789ABCDEF67890");//SHA1_SIZE*2 = 40 + fi1.name = "TestFile.txt"; + fi1.pop = 12; + fi1.age = 456; - fi2->filesize = 101010; - fi2->hash = RsFileHash("123456789ABCDEF67890123456789ABCDEF67890");//SHA1_SIZE*2 = 40 - fi2->name = "TestFile.txt"; - fi2->pop = 0; - fi2->age = 0;; + fi2.filesize = 101010; + fi2.hash = RsFileHash("123456789ABCDEF67890123456789ABCDEF67890");//SHA1_SIZE*2 = 40 + fi2.name = "TestFile.txt"; + fi2.pop = 0; + fi2.age = 0;; std::vector items; items.resize(4); - items[0] = bd1; - items[1] = bd2; - items[2] = fi1; - items[3] = fi2; + items[0] = &bd1; + items[1] = &bd2; + items[2] = &fi1; + items[3] = &fi2; test_TlvSet(items, 1024); }