MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / array_vec

Function array_vec

src/ext/arrayvec.rs:192–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190
191 #[test]
192 fn array_vec() {
193 let mut v = ArrayVec::<u8, 2>::default();
194 v.push(0);
195 v.push(1);
196 let b = encode(&v);
197 assert!(decode::<ArrayVec<u8, 1>>(&b).is_err());
198 assert_eq!(decode::<ArrayVec<u8, 2>>(&b).unwrap(), v);
199 assert_eq!(
200 decode::<ArrayVec<u8, 3>>(&b).unwrap().as_slice(),
201 v.as_slice()
202 );
203 assert_eq!(
204 decode::<ArrayVec<u8, 500>>(&b).unwrap().as_slice(),
205 v.as_slice()
206 );
207 assert!(decode::<ArrayVec<u8, 0>>(&encode(&ArrayVec::<u8, 0>::default())).is_ok());
208
209 // Make sure LengthDecoder::any_greater_than works on large lengths too.
210 let mut v = ArrayVec::<u8, 500>::default();
211 for i in 0..500 {
212 v.push(i as u8);
213 }
214 let b = encode(&v);
215 assert!(decode::<ArrayVec<u8, 499>>(&b).is_err());
216 assert_eq!(decode::<ArrayVec<u8, 500>>(&b).unwrap(), v);
217 }
218
219 #[test]
220 fn array_string_bug() {

Callers

nothing calls this directly

Calls 1

encodeFunction · 0.85

Tested by

no test coverage detected