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

Function std_test

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

Source from the content-addressed store, hash-verified

26
27#[test]
28fn std_test() {
29 let mut halloc = StandardAlloc::default();
30 for _i in 1..10 { // heap test
31 let mut x = <StandardAlloc as Allocator<u8>>::alloc_cell(&mut halloc, 100000);
32 x.slice_mut()[0] = 4;
33 let mut y = <StandardAlloc as Allocator<u8>>::alloc_cell(&mut halloc, 110000);
34 y.slice_mut()[0] = 5;
35 let mut z = <StandardAlloc as Allocator<u8>>::alloc_cell(&mut halloc, 120000);
36 z.slice_mut()[0] = 6;
37 assert_eq!(y.slice()[0], 5);
38 halloc.free_cell(y);
39 assert_eq!(x.slice()[0], 4);
40 assert_eq!(x.slice()[9], 0);
41 assert_eq!(z.slice()[0], 6);
42 }
43
44}
45
46
47#[cfg(feature="unsafe")]

Callers

nothing calls this directly

Calls 2

slice_mutMethod · 0.45
free_cellMethod · 0.45

Tested by

no test coverage detected