smessmer / binary-layout

The binary-layout library allows type-safe, inplace, zero-copy access to structured binary data. You define a custom data layout and give it a slice of binary data, and it will allow you to read and write the fields defined in the layout from the binary data without having to copy any of the data. It's similar to transmuting to/from a #[repr(packed)] struct, but much safer.
Apache License 2.0
66 stars 9 forks source link

WIP: Added support for i128/u128, but currently failing tests. #3

Closed ckaran closed 2 years ago

ckaran commented 2 years ago

This PR contains updates to support *128, but there is a test failure:

failures:

---- fields::primitive::tests::test_i128_bigendian stdout ----
thread 'fields::primitive::tests::test_i128_bigendian' panicked at 'assertion failed: `(left == right)`
  left: `1000000000000000000000000000000`,
 right: `1000000000000000000000000000255`', src/fields/primitive.rs:489:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    fields::primitive::tests::test_i128_bigendian

test result: FAILED. 72 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Looks like -1 in the last byte, not sure why though.

ckaran commented 2 years ago

I realized that I made a mistake in how I wrote the tests. The offsets weren't large enough, so values were overlapping in the byte arrays. Now fixed in the other PR I'm about to make.