1 extern crate tokio_buf; 2 3 use tokio_buf::SizeHint; 4 5 #[test] size_hint()6fn size_hint() { 7 let hint = SizeHint::new(); 8 assert_eq!(hint.lower(), 0); 9 assert!(hint.upper().is_none()); 10 11 let mut hint = SizeHint::new(); 12 hint.set_lower(100); 13 assert_eq!(hint.lower(), 100); 14 assert!(hint.upper().is_none()); 15 16 let mut hint = SizeHint::new(); 17 hint.set_upper(200); 18 assert_eq!(hint.lower(), 0); 19 assert_eq!(hint.upper(), Some(200)); 20 21 let mut hint = SizeHint::new(); 22 hint.set_lower(100); 23 hint.set_upper(100); 24 assert_eq!(hint.lower(), 100); 25 assert_eq!(hint.upper(), Some(100)); 26 } 27 28 #[test] 29 #[should_panic] size_hint_lower_bigger_than_upper()30fn size_hint_lower_bigger_than_upper() { 31 let mut hint = SizeHint::new(); 32 hint.set_upper(100); 33 hint.set_lower(200); 34 } 35 36 #[test] 37 #[should_panic] size_hint_upper_less_than_lower()38fn size_hint_upper_less_than_lower() { 39 let mut hint = SizeHint::new(); 40 hint.set_lower(200); 41 hint.set_upper(100); 42 } 43