/* * libretroshare/src/serialiser: tlvbase_test.cc * * RetroShare Serialiser. * * Copyright 2007-2008 by Horatio. * * 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 #include #include #include "serialiser/rstlvbase.h" #include "util/rsnet.h" TEST(libretroshare_serialiser, test_RsTlvBase) { //uint32_t array[] = {0x122, 0x234}; char data[20]; memset((void*)data, 65, sizeof(data)); // In ASCII 'A' =65 std::string out; // First two bytes are type. data[0]=0; data[1]=0; // Next 4 bytes is size. data[2]=0; data[3]=0; data[4]=0; data[5]=10; uint32_t off =0; GetTlvString((void*)data, 20, &off, 0, out); EXPECT_TRUE(out == "AAAA"); std::cout << "Output is : " << out << std::endl; uint16_t data2[] = {0, 0, 0x0300}; uint16_t t = GetTlvSize((void*) data2); EXPECT_TRUE( t == ntohs(0x0300)); //std::cout << "GetTlvSize = " <