mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 17:22:21 +00:00
[rust] Add FlatBufferBuilder::force_defaults API (#5946)
* [rust] Add force_defaults method FlatBufferBuilder This works just like the same method already available in other languages. * Add binary format test for force_defaults
This commit is contained in:
@@ -2460,6 +2460,25 @@ mod byte_layouts {
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layout_09b_vtable_with_one_default_bool_force_defaults() {
|
||||
let mut b = flatbuffers::FlatBufferBuilder::new();
|
||||
check(&b, &[]);
|
||||
let off = b.start_table();
|
||||
check(&b, &[]);
|
||||
b.force_defaults(true);
|
||||
b.push_slot(fi2fo(0), false, false);
|
||||
b.end_table(off);
|
||||
check(&b, &[
|
||||
6, 0, // vtable bytes
|
||||
8, 0, // length of object including vtable offset
|
||||
7, 0, // start of bool value
|
||||
6, 0, 0, 0, // offset for start of vtable (int32)
|
||||
0, 0, 0, // padded to 4 bytes
|
||||
0, // bool value
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layout_10_vtable_with_one_int16() {
|
||||
let mut b = flatbuffers::FlatBufferBuilder::new();
|
||||
|
||||
Reference in New Issue
Block a user