MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / test_pack_bytes_i8

Function test_pack_bytes_i8

src/pack.rs:520–538  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

518
519 #[test]
520 fn test_pack_bytes_i8() {
521 assert_eq!(pack_bytes(&[1i8, 2, 3, 4, 5, 6, 7]).len(), 5);
522 assert_eq!(pack_bytes(&[-1i8, -2, -3, -4, -5, -6, -7]).len(), 6);
523 assert_eq!(pack_bytes(&[-3i8, -2, -1, 0, 1, 2, 3]).len(), 6);
524 assert_eq!(
525 pack_bytes(&[0i8, -1, 0, -1, 0, -1, 0]),
526 [9, (-1i8) as u8, 0b1010101]
527 );
528
529 for max in i8::MIN..i8::MAX {
530 for sub in [1, 2, 3, 4, 5, 15, 127] {
531 let min = max.saturating_sub(sub);
532 let original = [min, min, min, min, min, min, min, max];
533 let packed = pack_bytes(&original);
534 let unpacked = unpack_bytes(&packed, original.len());
535 assert_eq!(original.as_slice(), unpacked.as_slice());
536 }
537 }
538 }
539
540 #[test]
541 fn unpack_bytes_errors() {

Callers

nothing calls this directly

Calls 3

pack_bytesFunction · 0.85
unpack_bytesFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected