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() {
171171 assert ! ( heap. allocate_first_fit( size_of:: <usize >( ) , 1 ) . is_some( ) ) ;
172172}
173173
174-
175174#[ test]
176175fn 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+ }
You can’t perform that action at this time.
0 commit comments