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

Function run_test_integer

cpp/fory/serialization/xlang_test_main.cc:1694–1727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1692}
1693
1694void run_test_integer(const std::string &data_file) {
1695 auto bytes = read_file(data_file);
1696 auto fory = build_fory(true, true);
1697 ensure_ok(fory.register_struct<Item1>(101), "register Item1");
1698 Buffer buffer = make_buffer(bytes);
1699
1700 Item1 expected;
1701 expected.f1 = 1;
1702 expected.f2 = 2;
1703 expected.f3 = 3;
1704 expected.f4 = 4;
1705 expected.f5 = 0;
1706 expected.f6 = 0;
1707
1708 auto item_value = read_next<Item1>(fory, buffer);
1709 if (!(item_value == expected)) {
1710 fail("Item1 mismatch");
1711 }
1712 // Note: we do not consume the trailing primitive integers from the
1713 // Java-produced payload here. They are validated on the Java and Rust
1714 // sides and re-written by the C++ side below for the C++ -> Java
1715 // round-trip.
1716
1717 std::vector<uint8_t> out;
1718 append_serialized(fory, item_value, out);
1719 append_serialized(fory, 1, out);
1720 append_serialized(fory, 2, out);
1721 append_serialized(fory, std::optional<int32_t>(3), out);
1722 append_serialized(fory, std::optional<int32_t>(4), out);
1723 // xlang mode uses nullable=false by default, so write 0 not null
1724 append_serialized(fory, 0, out);
1725 append_serialized(fory, 0, out);
1726 write_file(data_file, out);
1727}
1728
1729void run_test_decimal(const std::string &data_file) {
1730 auto bytes = read_file(data_file);

Callers 1

mainFunction · 0.85

Calls 7

read_fileFunction · 0.85
ensure_okFunction · 0.85
make_bufferFunction · 0.85
failFunction · 0.85
append_serializedFunction · 0.85
write_fileFunction · 0.85
build_foryFunction · 0.70

Tested by

no test coverage detected