Update h2-support to std-future
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							c8fefd49f1
						
					
				
				
					commit
					529ef4cd40
				
			| @@ -1,9 +1,10 @@ | ||||
|  | ||||
| #[macro_export] | ||||
| macro_rules! assert_closed { | ||||
|     ($transport:expr) => {{ | ||||
|         assert_eq!($transport.poll().unwrap(), None.into()); | ||||
|     }} | ||||
|         use futures::StreamExt; | ||||
|  | ||||
|         assert!($transport.next().await.is_none()); | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| @@ -13,7 +14,7 @@ macro_rules! assert_headers { | ||||
|             h2::frame::Frame::Headers(v) => v, | ||||
|             f => panic!("expected HEADERS; actual={:?}", f), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| @@ -23,7 +24,7 @@ macro_rules! assert_data { | ||||
|             h2::frame::Frame::Data(v) => v, | ||||
|             f => panic!("expected DATA; actual={:?}", f), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| @@ -33,7 +34,7 @@ macro_rules! assert_ping { | ||||
|             h2::frame::Frame::Ping(v) => v, | ||||
|             f => panic!("expected PING; actual={:?}", f), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| @@ -43,28 +44,56 @@ macro_rules! assert_settings { | ||||
|             h2::frame::Frame::Settings(v) => v, | ||||
|             f => panic!("expected SETTINGS; actual={:?}", f), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| macro_rules! poll_err { | ||||
|     ($transport:expr) => {{ | ||||
|         match $transport.poll() { | ||||
|             Err(e) => e, | ||||
|         use futures::StreamExt; | ||||
|         match $transport.next().await { | ||||
|             Some(Err(e)) => e, | ||||
|             frame => panic!("expected error; actual={:?}", frame), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| macro_rules! poll_frame { | ||||
|     ($type: ident, $transport:expr) => {{ | ||||
|         use futures::StreamExt; | ||||
|         use h2::frame::Frame; | ||||
|         use futures::Async; | ||||
|  | ||||
|         match $transport.poll() { | ||||
|             Ok(Async::Ready(Some(Frame::$type(frame)))) => frame, | ||||
|         match $transport.next().await { | ||||
|             Some(Ok(Frame::$type(frame))) => frame, | ||||
|             frame => panic!("unexpected frame; actual={:?}", frame), | ||||
|         } | ||||
|     }} | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| #[macro_export] | ||||
| macro_rules! assert_default_settings { | ||||
|     ($settings: expr) => {{ | ||||
|         assert_frame_eq($settings, frame::Settings::default()); | ||||
|     }}; | ||||
| } | ||||
|  | ||||
| use h2::frame::Frame; | ||||
|  | ||||
| pub fn assert_frame_eq<T: Into<Frame>, U: Into<Frame>>(t: T, u: U) { | ||||
|     let actual: Frame = t.into(); | ||||
|     let expected: Frame = u.into(); | ||||
|     match (actual, expected) { | ||||
|         (Frame::Data(a), Frame::Data(b)) => { | ||||
|             assert_eq!( | ||||
|                 a.payload().len(), | ||||
|                 b.payload().len(), | ||||
|                 "assert_frame_eq data payload len" | ||||
|             ); | ||||
|             assert_eq!(a, b, "assert_frame_eq"); | ||||
|         } | ||||
|         (a, b) => { | ||||
|             assert_eq!(a, b, "assert_frame_eq"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user