use std::mem; use elfps::*; use header::{HeaderPt1, HeaderPt2_}; fn mk_elf_header(class: u8) -> Vec { let header_size = mem::size_of::() + match class { 1 => mem::size_of::>(), 2 => mem::size_of::>(), _ => 0, }; let mut header = vec![0x7f, 'E' as u8, 'L' as u8, 'F' as u8]; let data = 1u8; let version = 1u8; header.extend_from_slice(&[class, data, version]); header.resize(header_size, 0); header } #[test] fn interpret_class() { assert!(ElfFile::new(&mk_elf_header(0)).is_err()); assert!(ElfFile::new(&mk_elf_header(1)).is_ok()); assert!(ElfFile::new(&mk_elf_header(2)).is_ok()); assert!(ElfFile::new(&mk_elf_header(42u8)).is_err()); }