Skip to content

Commit

Permalink
add assertions that struct alignment is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
bkietz committed Oct 25, 2024
1 parent 043856d commit 8b19902
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions arrow-ipc/regen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ for f in `ls *.rs`; do
fi
done

# Since $FLATC might be unpatched, add assertions that we have correct struct alignment
function add_struct_alignment_test {
>>"$1" cat <<'HEREDOC'
#[cfg(test)]
mod tests {
use super::*;
use flatbuffers::Push;
#[test]
fn struct_alignment() {
// https://github.com/google/flatbuffers/pull/8398
assert_eq!($2::alignment(), PushAlignment::new(8));
}
}
HEREDOC
}
add_struct_alignment_test Schema.rs Buffer
add_struct_alignment_test Message.rs FieldNode
add_struct_alignment_test File.rs Block

# Return back to base directory
popd
cargo +stable fmt -- src/gen/*
Expand Down
12 changes: 12 additions & 0 deletions arrow-ipc/src/gen/File.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,15 @@ pub fn finish_size_prefixed_footer_buffer<'a, 'b, A: flatbuffers::Allocator + 'a
) {
fbb.finish_size_prefixed(root, None);
}

#[cfg(test)]
mod tests {
use super::*;
use flatbuffers::Push;

#[test]
fn struct_alignment() {
// https://github.com/google/flatbuffers/pull/8398
assert_eq!(Block::alignment(), PushAlignment::new(8));
}
}
12 changes: 12 additions & 0 deletions arrow-ipc/src/gen/Message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,3 +1498,15 @@ pub fn finish_size_prefixed_message_buffer<'a, 'b, A: flatbuffers::Allocator + '
) {
fbb.finish_size_prefixed(root, None);
}

#[cfg(test)]
mod tests {
use super::*;
use flatbuffers::Push;

#[test]
fn struct_alignment() {
// https://github.com/google/flatbuffers/pull/8398
assert_eq!(FieldNode::alignment(), PushAlignment::new(8));
}
}
12 changes: 12 additions & 0 deletions arrow-ipc/src/gen/Schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5602,3 +5602,15 @@ pub fn finish_size_prefixed_schema_buffer<'a, 'b, A: flatbuffers::Allocator + 'a
) {
fbb.finish_size_prefixed(root, None);
}

#[cfg(test)]
mod tests {
use super::*;
use flatbuffers::Push;

#[test]
fn struct_alignment() {
// https://github.com/google/flatbuffers/pull/8398
assert_eq!(Buffer::alignment(), PushAlignment::new(8));
}
}

0 comments on commit 8b19902

Please sign in to comment.