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

Function std_unsafe_heap_test

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

Source from the content-addressed store, hash-verified

47#[cfg(feature="unsafe")]
48#[test]
49fn std_unsafe_heap_test() {
50 let mut halloc = unsafe{HeapAllocUninitialized::<u8>::new()};
51 for _i in 1..10 { // heap test
52 let mut x = halloc.alloc_cell(100000);
53 x.slice_mut()[0] = 4;
54 let mut y = halloc.alloc_cell(110000);
55 y.slice_mut()[0] = 5;
56 let mut z = halloc.alloc_cell(120000);
57 z.slice_mut()[0] = 6;
58 assert_eq!(y.slice()[0], 5);
59 halloc.free_cell(y);
60 assert_eq!(x.slice()[0], 4);
61 assert_eq!(x.slice()[9], 0);
62 assert_eq!(z.slice()[0], 6);
63 }
64
65}
66
67#[cfg(feature="stdlib")]
68#[test]

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