/* * libretroshare/src/serialiser: rsturtleitems_test.cc * * RetroShare Serialiser. * * Copyright 2007-2008 by Cyril Soler * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License Version 2 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Please report all bugs and problems to "retroshare@lunamutt.com". * */ /****************************************************************** */ #include #include #include "turtle/rsturtleitem.h" #include #include "support.h" #include "util/utest.h" INITTEST(); RsSerialType* init_item(CompressedChunkMap& map) { map._map.clear() ; for(uint32_t i=0;i<15;++i) map._map.push_back(rand()) ; return new RsTurtleSerialiser(); } bool operator==(const CompressedChunkMap& m1,const CompressedChunkMap& m2) { if(m1._map.size() != m2._map.size()) return false ; for(uint32_t i=0;i::const_iterator i1(it1.result.begin()) ; std::list::const_iterator i2(it2.result.begin()) ; for(;i1!=it1.result.end() && i2!=it2.result.end();++i1,++i2) if( !(*i1 == *i2)) return false ; return true ; } int main() { std::cerr << "RsTurtleItem Tests" << std::endl; for(uint32_t i=0;i<20;++i) { test_RsItem(); REPORT("Serialise/Deserialise RsTurtleFileMapRequestItem"); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleFileMapItem"); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleFileDataItem"); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleFileRequestItem"); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleTunnelOkItem "); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleOpenTunnelItem "); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleSearchResultItem "); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleStringSearchRequestItem "); test_RsItem(); REPORT("Serialise/Deserialise RsTurtleRegExpSearchRequestItem "); } FINALREPORT("RsturtleItem Tests"); return TESTRESULT(); }