use arm_attr::{enums::*, globals::*, read::Endian, BuildAttrs};
#[test]
fn test_inheritance() {
#[rustfmt::skip]
let raw = [
b'A', 0x3e, 0x00, 0x00, 0x00, b'a', b'e', b'a', b'b', b'i', 0, Tag_File, 0x34, 0x00, 0x00, 0x00, Tag_CPU_arch, 4, Tag_Section, 0x13, 0x00, 0x00, 0x00, 53, 42, 0, Tag_Symbol, 0x09, 0x00, 0x00, 0x00, 99, 0, Tag_THUMB_ISA_use, 1, Tag_FP_arch, 1, Tag_Section, 0x1a, 0x00, 0x00, 0x00, 1, 0, Tag_Symbol, 0x08, 0x00, 0x00, 0x00, 77, 66, 0, Tag_Symbol, 0x09, 0x00, 0x00, 0x00, 88, 0, Tag_THUMB_ISA_use, 1, Tag_nodefaults, 0,
];
let build_attrs = BuildAttrs::new(&raw, Endian::Little).unwrap();
let mut subsections = build_attrs.subsections().map(|s| s.unwrap());
let subsection = subsections.next().unwrap();
assert!(subsection.is_aeabi());
let file = subsection.into_public_attributes().unwrap();
assert_eq!(file.attributes.cpu_arch, Some(CpuArch::V5TE));
let section = file.sections.get([53, 42].as_ref()).unwrap();
assert_eq!(section.attributes.cpu_arch, None);
assert_eq!(section.attributes.thumb_isa_use, None);
let symbol = section.symbols.get([99].as_ref()).unwrap();
assert_eq!(symbol.attributes.cpu_arch, None);
assert_eq!(symbol.attributes.thumb_isa_use, Some(ThumbIsaUse::Allowed16Bit));
let section = file.sections.get([1].as_ref()).unwrap();
assert_eq!(section.attributes.cpu_arch, Some(CpuArch::V5TE));
let symbol = section.symbols.get([77, 66].as_ref()).unwrap();
assert_eq!(symbol.attributes.cpu_arch, None);
let symbol = section.symbols.get([88].as_ref()).unwrap();
assert_eq!(symbol.attributes.cpu_arch, None);
assert_eq!(symbol.attributes.thumb_isa_use, Some(ThumbIsaUse::Allowed16Bit));
}