void Message <Args...>::get (F f) const { std::function <void (bool, Args...)> func (f); for (auto && element : _elements) { Unpacker <Args..., void> unpacker; StreamBinIn sbi (element.second); unpacker.unpack (func, element.first, sbi); // deserialize, get direction, call f } }
TEST(unpacker, with_1_error_in_data) { bool packetArray[101] = {1,0,1,0,0,0,1,0,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0,1,0,0,1,1,1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0,0,1,1,0,0,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}; vector<bool> packet (packetArray, packetArray + sizeof(packetArray) / sizeof(bool) ); bool correctArray[48] = { 1,1,0,1,0,0,1,1,1,0,1,0,1,0,0,1,0,1,0,1,1,1,0,1,0,0,1,0,1,1,0,1,1,0,1,1,1,1,0,0,1,0,0,1,0,1,0,0 }; vector<bool> correct (correctArray, correctArray + sizeof(correctArray) / sizeof(bool) ); vector<bool> output; // output of function Unpacker unpacker; unpacker.unpack(packet, output); ASSERT_THAT(output, testing::ContainerEq(correct)); }
void NetExplosion::read(Unpacker & unpacker) { unpacker.unpack(pos.x); unpacker.unpack(pos.y); }
void NetGameDataTdm::read(Unpacker & unpacker) { unpacker.unpack(scoreA); unpacker.unpack(scoreB); }