Skip to content

Commit 7bf28e8

Browse files
committed
Add failing test for phil-opp/blog_os#160
1 parent fcb9b61 commit 7bf28e8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/test.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ fn allocate_usize() {
171171
assert!(heap.allocate_first_fit(size_of::<usize>(), 1).is_some());
172172
}
173173

174-
175174
#[test]
176175
fn allocate_usize_in_bigger_block() {
177176
let mut heap = new_heap();
@@ -192,3 +191,14 @@ fn allocate_usize_in_bigger_block() {
192191
heap.deallocate(z, size_of::<usize>(), 1);
193192
}
194193
}
194+
195+
#[test]
196+
// see https://github.com/phil-opp/blog_os/issues/160
197+
fn align_from_small_to_big() {
198+
let mut heap = new_heap();
199+
200+
// allocate 28 bytes so that the heap end is only 4 byte aligned
201+
assert!(heap.allocate_first_fit(28, 4).is_some());
202+
// try to allocate a 8 byte aligned block
203+
assert!(heap.allocate_first_fit(8, 8).is_some());
204+
}

0 commit comments

Comments
 (0)