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

Function std_heap_test

alloc-stdlib/src/bin/tests.rs:69–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67#[cfg(feature="stdlib")]
68#[test]
69fn std_heap_test() {
70 let mut halloc = HeapAlloc::<u8>::new(0);
71 for _i in 1..10 { // heap test
72 let mut x = halloc.alloc_cell(100000);
73 x.slice_mut()[0] = 4;
74 let mut y = halloc.alloc_cell(110000);
75 y.slice_mut()[0] = 5;
76 let mut z = halloc.alloc_cell(120000);
77 z.slice_mut()[0] = 6;
78 assert_eq!(y.slice()[0], 5);
79 halloc.free_cell(y);
80 assert_eq!(x.slice()[0], 4);
81 assert_eq!(x.slice()[9], 0);
82 assert_eq!(z.slice()[0], 6);
83 }
84
85}

Callers

nothing calls this directly

Calls 3

alloc_cellMethod · 0.45
slice_mutMethod · 0.45
free_cellMethod · 0.45

Tested by

no test coverage detected