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

Function TEST

cpp/fory/serialization/stream_test.cc:159–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159TEST(StreamSerializationTest, PrimitiveAndStringRoundTrip) {
160 auto fory =
161 Fory::builder().xlang(true).compatible(false).track_ref(false).build();
162
163 auto number_bytes_result = fory.serialize<int64_t>(-9876543212345LL);
164 ASSERT_TRUE(number_bytes_result.ok())
165 << number_bytes_result.error().to_string();
166 OneByteIStream number_source(std::move(number_bytes_result).value());
167 StdInputStream number_stream(number_source, 8);
168 auto number_result = fory.deserialize<int64_t>(number_stream);
169 ASSERT_TRUE(number_result.ok()) << number_result.error().to_string();
170 EXPECT_EQ(number_result.value(), -9876543212345LL);
171
172 auto string_bytes_result = fory.serialize<std::string>("stream-hello-世界");
173 ASSERT_TRUE(string_bytes_result.ok())
174 << string_bytes_result.error().to_string();
175 OneByteIStream string_source(std::move(string_bytes_result).value());
176 StdInputStream string_stream(string_source, 8);
177 auto string_result = fory.deserialize<std::string>(string_stream);
178 ASSERT_TRUE(string_result.ok()) << string_result.error().to_string();
179 EXPECT_EQ(string_result.value(), "stream-hello-世界");
180}
181
182TEST(StreamSerializationTest, StructRoundTrip) {
183 auto fory =

Callers

nothing calls this directly

Calls 15

register_stream_typesFunction · 0.85
reader_indexMethod · 0.80
get_bufferMethod · 0.80
errorMethod · 0.65
valueMethod · 0.65
serializeMethod · 0.65
stringFunction · 0.50
buildMethod · 0.45
track_refMethod · 0.45
compatibleMethod · 0.45
xlangMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected