11#include < cstdint>
2+ #include < iostream>
3+ #include < stdexcept>
24#include < string>
35#include < vector>
46
57#include " qdata.h"
68
79namespace {
810
11+ void debug_log (const char * message) {
12+ std::cerr << " [qdata_buffer_api] " << message << ' \n ' ;
13+ std::cerr.flush ();
14+ }
15+
916void expect_integer_payload (const qdata::object& obj, const std::vector<std::int32_t >& expected) {
1017 if (!qdata::holds_alternative<qdata::integer_vector>(obj)) {
1118 throw std::runtime_error (" unexpected payload type" );
@@ -25,19 +32,29 @@ void expect_integer_payload(const qdata::object& obj, const std::vector<std::int
2532} // namespace
2633
2734int main () {
35+ debug_log (" start" );
2836 const std::vector<std::int32_t > input{1 , 2 , 3 , 4 };
2937
38+ debug_log (" serialize std::vector<std::byte>" );
3039 const auto bytes = qdata::serialize (input);
40+ debug_log (" deserialize std::vector<std::byte>" );
3141 expect_integer_payload (qdata::deserialize (bytes), input);
3242
43+ debug_log (" serialize std::vector<char>" );
3344 const auto chars = qdata::serialize<std::vector<char >>(input);
45+ debug_log (" deserialize std::vector<char>" );
3446 expect_integer_payload (qdata::deserialize (chars), input);
3547
48+ debug_log (" serialize std::vector<std::uint8_t>" );
3649 const auto uints = qdata::serialize<std::vector<std::uint8_t >>(input);
50+ debug_log (" deserialize std::vector<std::uint8_t>" );
3751 expect_integer_payload (qdata::deserialize (uints), input);
3852
53+ debug_log (" serialize std::string" );
3954 const auto text = qdata::serialize<std::string>(input);
55+ debug_log (" deserialize std::string" );
4056 expect_integer_payload (qdata::deserialize (text), input);
4157
58+ debug_log (" done" );
4259 return 0 ;
4360}
0 commit comments