File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,6 @@ fn allocate_usize() {
171
171
assert ! ( heap. allocate_first_fit( size_of:: <usize >( ) , 1 ) . is_some( ) ) ;
172
172
}
173
173
174
-
175
174
#[ test]
176
175
fn allocate_usize_in_bigger_block ( ) {
177
176
let mut heap = new_heap ( ) ;
@@ -192,3 +191,14 @@ fn allocate_usize_in_bigger_block() {
192
191
heap. deallocate ( z, size_of :: < usize > ( ) , 1 ) ;
193
192
}
194
193
}
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
+ }
You can’t perform that action at this time.
0 commit comments