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

Function insert_remove

cranelift/entity/src/list.rs:798–831  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

796
797 #[test]
798 fn insert_remove() {
799 let pool = &mut ListPool::<Inst>::new();
800 let mut list = EntityList::<Inst>::default();
801
802 let i1 = Inst::new(1);
803 let i2 = Inst::new(2);
804 let i3 = Inst::new(3);
805 let i4 = Inst::new(4);
806
807 list.insert(0, i4, pool);
808 assert_eq!(list.as_slice(pool), &[i4]);
809
810 list.insert(0, i3, pool);
811 assert_eq!(list.as_slice(pool), &[i3, i4]);
812
813 list.insert(2, i2, pool);
814 assert_eq!(list.as_slice(pool), &[i3, i4, i2]);
815
816 list.insert(2, i1, pool);
817 assert_eq!(list.as_slice(pool), &[i3, i4, i1, i2]);
818
819 list.remove(3, pool);
820 assert_eq!(list.as_slice(pool), &[i3, i4, i1]);
821
822 list.remove(2, pool);
823 assert_eq!(list.as_slice(pool), &[i3, i4]);
824
825 list.remove(0, pool);
826 assert_eq!(list.as_slice(pool), &[i4]);
827
828 list.remove(0, pool);
829 assert_eq!(list.as_slice(pool), &[]);
830 assert!(list.is_empty());
831 }
832
833 #[test]
834 fn growing() {

Callers

nothing calls this directly

Calls 3

newFunction · 0.50
insertMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected