#[test]
fn fat_binary_too_small_is_error() {
let data = [0xCA, 0xFE, 0xBA, 0xBE];
let result = macho_core::format::fat::parse_fat_binary(&data);
assert!(result.is_err());
}
#[test]
fn fat_binary_zero_arches_is_error() {
let mut data = Vec::new();
data.extend_from_slice(&0xCAFE_BABEu32.to_be_bytes()); data.extend_from_slice(&0u32.to_be_bytes()); let result = macho_core::format::fat::parse_fat_binary(&data);
assert!(result.is_err());
}
#[test]
fn fat_binary_duplicate_architectures_are_rejected() {
let data = macho_test_support::fat32(&[
(
macho_test_support::CPU_TYPE_ARM64,
0,
macho_test_support::thin64_arm64(2),
),
(
macho_test_support::CPU_TYPE_ARM64,
0,
macho_test_support::thin64_arm64(2),
),
]);
let error = macho_core::format::fat::parse_fat_binary(&data).unwrap_err();
assert_eq!(error.kind, macho_core::ParseErrorKind::InvalidFormat);
assert!(error.message().contains("duplicate fat architecture"));
}
#[test]
fn fat_binary_misaligned_slice_is_rejected() {
let mut data = macho_test_support::fat32(&[(
macho_test_support::CPU_TYPE_ARM64,
0,
macho_test_support::thin64_arm64(2),
)]);
data[24..28].copy_from_slice(&13u32.to_be_bytes());
let error = macho_core::format::fat::parse_fat_binary(&data).unwrap_err();
assert_eq!(error.kind, macho_core::ParseErrorKind::InvalidFormat);
assert!(error.message().contains("is not aligned"));
}