//! Compilation tests: they only test if the compilation fails, not the //! macro output use log; use micro_timer::timed; #[test] fn check_name_conflict() { #[timed] fn thing(_value: usize) -> usize { let timer = 10; timer } assert_eq!(thing(1), 10 as usize); } #[test] fn test_mut() { #[timed] fn thing(mut value: usize) { println!("{}", value); value = 5; println!("{}", value); } thing(1); } #[test] fn test_ref_mut() { #[timed] fn thing(value: &mut String) { value.push('a'); } let mut a = String::new(); thing(&mut a); assert_eq!("a", a); } #[test] fn test_fn_mut() { #[timed] fn thing(value: &mut String) { value.push('a'); } let mut a = String::new(); thing(&mut a); assert_eq!("a", a); } #[test] fn test_mut_struct() { #[timed] fn thing(value: Thing) -> &mut String { value.value } let mut s = String::new(); struct Thing<'a> { value: &'a mut String, } thing(Thing { value: &mut s }); } #[test] fn test_mut_pointer() { #[timed] fn thing(value: *mut u8) { unsafe { *value != 0u8 }; } let mut s = String::new(); thing(s.as_mut_ptr()); }