GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cppack/msgpack/tests/examples.cpp at master · wsjcpp/cppack Expand file tree/ Copy pathexamples.cppMore file actions 38 lines (30 loc) · 1.02 KB / Copy pathexamples.cppFile metadata and controls38 lines (30 loc) · 1.02 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 // // Created by Mike Loomis on 6/28/2019. // #include <catch2/catch.hpp> #include "msgpack/msgpack.hpp" struct Example { std::map<std::string, bool> map; template<class T> void pack(T &pack) { pack(map); } }; TEST_CASE("Website example") { Example example{{{"compact", true}, {"schema", false}}}; auto data = msgpack::pack(example); REQUIRE(data.size() == 18); REQUIRE(data == std::vector<uint8_t>{0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0xc2}); REQUIRE(example.map == msgpack::unpack<Example>(data).map); } TEST_CASE("Unpack with error handling") { Example example{{{"compact", true}, {"schema", false}}}; auto data = std::vector<uint8_t>{0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73, 0x63}; std::error_code ec{}; auto unpacked_object = msgpack::unpack<Example>(data, ec); if (ec && ec == msgpack::UnpackerError::OutOfRange) REQUIRE(true); else REQUIRE(false); } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |