MCPcopy Create free account
hub / github.com/apache/fory / test_roundtrip

Function test_roundtrip

cpp/fory/serialization/struct_test.cc:702–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700}
701
702template <typename T> void test_roundtrip(const T &original) {
703 auto fory =
704 Fory::builder().xlang(true).compatible(false).track_ref(false).build();
705 register_all_test_types(fory);
706
707 auto serialize_result = fory.serialize(original);
708 ASSERT_TRUE(serialize_result.ok())
709 << "Serialization failed: " << serialize_result.error().to_string();
710
711 std::vector<uint8_t> bytes = std::move(serialize_result).value();
712 ASSERT_GT(bytes.size(), 0);
713
714 auto deserialize_result = fory.deserialize<T>(bytes.data(), bytes.size());
715 ASSERT_TRUE(deserialize_result.ok())
716 << "Deserialization failed: " << deserialize_result.error().to_string();
717
718 T deserialized = std::move(deserialize_result).value();
719 EXPECT_EQ(original, deserialized);
720}
721
722// ============================================================================
723// TESTS

Callers 1

TESTFunction · 0.70

Calls 12

register_all_test_typesFunction · 0.85
serializeMethod · 0.65
errorMethod · 0.65
valueMethod · 0.65
buildMethod · 0.45
track_refMethod · 0.45
compatibleMethod · 0.45
xlangMethod · 0.45
okMethod · 0.45
to_stringMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected