MCPcopy Create free account
hub / github.com/dropbox/rust-alloc-no-stdlib / test_index_ops

Function test_index_ops

alloc-stdlib/src/test.rs:95–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93
94#[test]
95fn test_index_ops() {
96 let array = [255u8, 0u8, 1u8,2u8,3u8,4u8,5u8, 6u8];
97 let sl = SliceReference::<u8>::new(&array[..], 1, 5);
98 let val = sl[0];
99 assert_eq!(val, 0);
100 assert_eq!(&sl[1..5], &[1u8,2u8,3u8,4u8]);
101 let mut al =ItemVecAllocator::<u64>::default();
102 let mut dat = al.alloc_cell(1024);
103 dat[0] = 0;
104 dat[1] = 1;
105 dat[2] = 2;
106 dat[3] = 3;
107 assert_eq!(dat[1], 1);
108 assert_eq!(&dat[1..5], &[1u64,2u64,3u64,0u64]);
109 assert_eq!(dat.len(), 1024);
110 al.free_cell(dat);
111
112}

Callers

nothing calls this directly

Calls 2

alloc_cellMethod · 0.45
free_cellMethod · 0.45

Tested by

no test coverage detected