@@ -171,26 +171,32 @@ mod tests {
171171 fn test_allocate_with_alignment_first_ok ( ) {
172172 let mut pool = AddressAllocator :: new ( 0x1000 , 0x1000 ) . unwrap ( ) ;
173173 assert_eq ! ( pool. available( ) , 0x1000 ) ;
174- // Allocate aligned 0x110
174+ // Allocate 0x110
175175 assert_eq ! (
176176 pool. allocate( 0x110 , 0x100 , AllocPolicy :: FirstMatch )
177177 . unwrap( ) ,
178178 RangeInclusive :: new( 0x1000 , 0x110F ) . unwrap( )
179179 ) ;
180180 assert_eq ! ( pool. available( ) , 0x1000 - 0x110 ) ;
181- // Allocate aligned 0x100
181+ // Allocate 0x100
182182 assert_eq ! (
183183 pool. allocate( 0x100 , 0x100 , AllocPolicy :: FirstMatch )
184184 . unwrap( ) ,
185185 RangeInclusive :: new( 0x1200 , 0x12FF ) . unwrap( )
186186 ) ;
187187 assert_eq ! ( pool. available( ) , 0x1000 - 0x110 - 0x100 ) ;
188- // Allocate unaligned 0x10
188+ // Allocate 0x10
189189 assert_eq ! (
190190 pool. allocate( 0x10 , 0x100 , AllocPolicy :: FirstMatch ) . unwrap( ) ,
191191 RangeInclusive :: new( 0x1300 , 0x130F ) . unwrap( )
192192 ) ;
193- assert_eq ! ( pool. available( ) , 0x1000 - 0x110 - 0x100 - 0x100 ) ;
193+ assert_eq ! ( pool. available( ) , 0x1000 - 0x110 - 0x100 - 0x10 ) ;
194+ // Allocate unaligned size 101
195+ assert_eq ! (
196+ pool. allocate( 101 , 0x100 , AllocPolicy :: FirstMatch ) . unwrap( ) ,
197+ RangeInclusive :: new( 0x1400 , 0x14FF ) . unwrap( )
198+ ) ;
199+ assert_eq ! ( pool. available( ) , 0x1000 - 0x110 - 0x100 - 0x10 - 0x100 ) ;
194200 }
195201
196202 #[ test]
0 commit comments