MCPcopy Index your code
hub / github.com/dropbox/rust-alloc-no-stdlib / heap_test

Function heap_test

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

Source from the content-addressed store, hash-verified

7use alloc_stdlib::HeapAllocUninitialized;
8#[test]
9fn heap_test() {
10 let mut halloc : HeapAlloc<u8> = HeapAlloc::<u8>{default_value: 0};
11 for _i in 1..10 { // heap test
12 let mut x = halloc.alloc_cell(100000);
13 x.slice_mut()[0] = 4;
14 let mut y = halloc.alloc_cell(110000);
15 y.slice_mut()[0] = 5;
16 let mut z = halloc.alloc_cell(120000);
17 z.slice_mut()[0] = 6;
18 assert_eq!(y.slice()[0], 5);
19 halloc.free_cell(y);
20 assert_eq!(x.slice()[0], 4);
21 assert_eq!(x.slice()[9], 0);
22 assert_eq!(z.slice()[0], 6);
23 }
24
25}
26
27#[test]
28fn std_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