()
| 136 | |
| 137 | #[test] |
| 138 | fn test_ml_decoder() { |
| 139 | struct Test(String, Option<String>, String); |
| 140 | let tests = vec![ |
| 141 | Test("".to_string(), None, "".to_string()), |
| 142 | Test( |
| 143 | "{\"hello\":\"world\"}\n\nremainder".to_string(), |
| 144 | Some("{\"hello\":\"world\"}".to_string()), |
| 145 | "remainder".to_string(), |
| 146 | ), |
| 147 | Test( |
| 148 | "{\"hello\":\"world\"}\n\n{}\n\nremainder".to_string(), |
| 149 | Some("{\"hello\":\"world\"}".to_string()), |
| 150 | "{}\n\nremainder".to_string(), |
| 151 | ), |
| 152 | ]; |
| 153 | |
| 154 | for t in tests.iter() { |
| 155 | let mut buf = BytesMut::new(); |
| 156 | buf.put_slice(t.0.as_bytes()); |
| 157 | |
| 158 | let mut codec = MultiLineCodec::default(); |
| 159 | let mut remainder = BytesMut::new(); |
| 160 | remainder.put_slice(t.2.as_bytes()); |
| 161 | |
| 162 | assert_eq!(codec.decode(&mut buf).unwrap(), t.1); |
| 163 | assert_eq!(buf, remainder); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | #[test] |
| 168 | fn test_ml_encoder() { |
nothing calls this directly
no outgoing calls
no test coverage detected