32 BOOST_HANA_DEFINE_STRUCT(TestObjectBinaryHana, (
int, number), (
double, number2), (vector<int>, numbers), (
string, text), (
bool,
boolean));
36 BOOST_HANA_DEFINE_STRUCT(NestingArrayBinaryHana, (
string, name), (vector<TestObjectBinaryHana>, testObjects));
71 TestObjectBinaryHana testObject;
72 testObject.number = 42;
73 testObject.number2 = 1234.25;
74 testObject.numbers = { 1, 2, 3, 4, 5 };
75 testObject.text =
"foo";
76 testObject.boolean =
true;
78 NestingArrayBinaryHana nestingObject;
79 nestingObject.name =
"bar";
80 nestingObject.testObjects.emplace_back(testObject);
82 stringstream stream(ios_base::in | ios_base::out | ios_base::binary);
83 stream.exceptions(ios_base::failbit | ios_base::badbit);
84 nestingObject.toBinary(stream);
86 const auto deserializedObject(NestingArrayBinaryHana::fromBinary(stream));
87 const auto &deserializedTestObj(deserializedObject.testObjects.at(0));
88 CPPUNIT_ASSERT_EQUAL(nestingObject.name, deserializedObject.name);
89 CPPUNIT_ASSERT_EQUAL(testObject.number, deserializedTestObj.number);
90 CPPUNIT_ASSERT_EQUAL(testObject.number2, deserializedTestObj.number2);
91 CPPUNIT_ASSERT_EQUAL(testObject.numbers, deserializedTestObj.numbers);
92 CPPUNIT_ASSERT_EQUAL(testObject.text, deserializedTestObj.text);
93 CPPUNIT_ASSERT_EQUAL(testObject.boolean, deserializedTestObj.boolean);