1 #![cfg(feature = "read")] 2 use object::{File, Object}; 3 use std::{env, fs}; 4 5 #[test] parse_self()6fn parse_self() { 7 let exe = env::current_exe().unwrap(); 8 let data = fs::read(exe).unwrap(); 9 let object = File::parse(&*data).unwrap(); 10 assert!(object.entry() != 0); 11 assert!(object.sections().count() != 0); 12 } 13 14 #[cfg(feature = "std")] 15 #[test] parse_self_cache()16fn parse_self_cache() { 17 use object::read::{ReadCache, ReadRef}; 18 let exe = env::current_exe().unwrap(); 19 let file = fs::File::open(exe).unwrap(); 20 let cache = ReadCache::new(file); 21 let data = cache.range(0, cache.len().unwrap()); 22 let object = File::parse(data).unwrap(); 23 assert!(object.entry() != 0); 24 assert!(object.sections().count() != 0); 25 } 26