-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
38 lines (32 loc) · 826 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#[cfg(test)]
mod tests {
// Struct used for testing.
struct Entity {
_a: i32,
_b: i32,
_c: i32,
}
use std::mem;
use freelist::Freelist;
#[test]
fn default_constructor() {
let fl = Freelist::<Entity>::new();
assert_eq!(fl.capacity_blocks(), 0);
assert_eq!(fl.used_blocks(), 0);
assert_eq!(fl.free_blocks(), 0);
assert_eq!(fl.type_size_bytes(), mem::size_of::<Entity>() as i32);
}
#[test]
#[should_panic]
fn type_too_small() {
Freelist::<u32>::new();
}
#[test]
fn reserve_exact() {
let mut fl = Freelist::<Entity>::new();
fl.reserve_exact(100);
assert_eq!(fl.capacity_blocks(), 100);
fl.reserve_exact(150);
assert_eq!(fl.capacity_blocks(), 150);
}
}