From 58a50db413fc933032e9ee96ce841c28351e0e10 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 10 Jul 2026 20:44:02 +0200 Subject: [PATCH] test(rust): make entropy tests portable to 32-bit Use an explicitly 64-bit literal before narrowing it in the common-byte test, and derive the FSE compression-bound expectation from `size_of::()`. The tests now exercise the same public contracts on 32-bit and 64-bit targets instead of embedding a 64-bit-only compile-time assumption. Test Plan: - cargo clippy; cargo clippy --benches; cargo clippy --tests - cargo +nightly fmt, then repeat the Clippy checks - cargo test --target i686-unknown-linux-gnu --lib - cargo test --target i686-unknown-linux-gnu --lib --features \ huf-force-decompress-x1 - cargo test --target i686-unknown-linux-gnu --lib --features \ huf-force-decompress-x2 Refs: rust/README.md --- rust/src/bits.rs | 2 +- rust/src/fse_compress.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rust/src/bits.rs b/rust/src/bits.rs index 25e927634..38f70e283 100644 --- a/rust/src/bits.rs +++ b/rust/src/bits.rs @@ -103,7 +103,7 @@ mod tests { if MEM_isLittleEndian() { assert_eq!(ZSTD_NbCommonBytes(0x0000_0000_0001_0000), 2); } else if MEM_64bits() { - assert_eq!(ZSTD_NbCommonBytes(0x0001_0000_0000_0000), 2); + assert_eq!(ZSTD_NbCommonBytes(0x0001_0000_0000_0000u64 as usize), 2); } else { assert_eq!(ZSTD_NbCommonBytes(0x0001_0000), 2); } diff --git a/rust/src/fse_compress.rs b/rust/src/fse_compress.rs index feba9d7d6..660af8cee 100644 --- a/rust/src/fse_compress.rs +++ b/rust/src/fse_compress.rs @@ -992,7 +992,11 @@ mod tests { assert_eq!(result, 5); assert_eq!(normalized, [3, 1, 4, 1, 5, 10, 2, 6]); assert_eq!(FSE_NCountWriteBound(4, 5), 6); - assert_eq!(FSE_compressBound(33), 557); + let input_size = 33usize; + assert_eq!( + FSE_compressBound(input_size), + FSE_NCOUNTBOUND + input_size + (input_size >> 7) + 4 + size_of::() + ); assert_eq!(FSE_optimalTableLog(12, 33, 4), 5); }