MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / test_into_boxed_slice

Function test_into_boxed_slice

crates/core/src/alloc/vec.rs:502–526  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

500
501 #[test]
502 fn test_into_boxed_slice() -> Result<(), OutOfMemory> {
503 assert_eq!(*TryVec::<i32>::new().into_boxed_slice()?, []);
504
505 let mut vec = TryVec::new();
506 vec.push(1)?;
507 assert_eq!(*vec.into_boxed_slice()?, [1]);
508
509 let mut vec = TryVec::with_capacity(2)?;
510 vec.push(1)?;
511 assert_eq!(*vec.into_boxed_slice()?, [1]);
512
513 let mut vec = TryVec::with_capacity(2)?;
514 vec.push(1_u128)?;
515 assert_eq!(*vec.into_boxed_slice()?, [1]);
516
517 assert_eq!(*TryVec::<()>::new().into_boxed_slice()?, []);
518
519 let mut vec = TryVec::new();
520 vec.push(())?;
521 assert_eq!(*vec.into_boxed_slice()?, [()]);
522
523 let vec = TryVec::<i32>::with_capacity(2)?;
524 assert_eq!(*vec.into_boxed_slice()?, []);
525 Ok(())
526 }
527}

Callers

nothing calls this directly

Calls 3

OkFunction · 0.85
newFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected