MCPcopy Create free account
hub / github.com/Recordscript/recordscript / test_codec2

Function test_codec2

libs/hbb_common/src/bytes_codec.rs:176–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174
175 #[test]
176 fn test_codec2() {
177 let mut codec = BytesCodec::new();
178 let mut buf = BytesMut::new();
179 let mut bytes: Vec<u8> = Vec::new();
180 assert!(codec.encode("".into(), &mut buf).is_ok());
181 assert_eq!(buf.len(), 1);
182 bytes.resize(0x3F + 1, 2);
183 assert!(codec.encode(bytes.into(), &mut buf).is_ok());
184 assert_eq!(buf.len(), 0x3F + 2 + 2);
185 if let Ok(Some(res)) = codec.decode(&mut buf) {
186 assert_eq!(res.len(), 0);
187 } else {
188 panic!();
189 }
190 if let Ok(Some(res)) = codec.decode(&mut buf) {
191 assert_eq!(res.len(), 0x3F + 1);
192 assert_eq!(res[0], 2);
193 } else {
194 panic!();
195 }
196 }
197
198 #[test]
199 fn test_codec3() {

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected