/******************************************************************************* * unittests/libretroshare/serialiser/tlvbase_test.cc * * * * Copyright 2007-2008 by Horatio * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * * * This program 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 Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see . * * * ******************************************************************************/ #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 = " <