Simsys / tfmt

A tiny, fast and panic-free alternative to core::fmt
Apache License 2.0
0 stars 0 forks source link

u128::max_value() test with heapless::String fails #1

Open Simsys opened 3 months ago

Simsys commented 3 months ago
macro_rules! cmp {
    ($($tt:tt)*) => {
        assert_eq!(
            tfmt::uformat!(500, $($tt)*).unwrap().as_str(),
            format!($($tt)*).as_str(),
        )
    }
}

fn main() {
    cmp!("{}", u128::max_value());
}

The program runs in all tested constellations except one: AMD64, release, use of heapless::String. The same program works if core::string::String is used for uformat.

Ok Cortex M4, dev (no features)
Ok Cortex M4 release (no features)
Ok AMD64 dev (no features)
Ok AMD64 dev (features std)
Ok AMD64 release (features std)
NOK AMD64 release (no featues) 

With all other (u8, u16, u32, u64, i8, i16, i32, i64, i128) maximum and minimum values, everything works in all constellations.

Simsys commented 2 months ago

Error Output of the above program is

thread 'main' panicked at src/main.rs:11:5:
assertion `left == right` failed
  left: "'\0\0\0\0\0\0\06920938463463374607431766074455"
 right: "340282366920938463463374607431768211455"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Error output of cargo test --release (feature std not enabled)

thread 'uxx_min_max' panicked at tests/int.rs:9:5:
assertion `left == right` failed
  left: "340282366920938463463374607431766074455"
 right: "340282366920938463463374607431768211455"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace