@@ -171,26 +171,32 @@ mod tests {
171
171
fn test_allocate_with_alignment_first_ok ( ) {
172
172
let mut pool = AddressAllocator :: new ( 0x1000 , 0x1000 ) . unwrap ( ) ;
173
173
assert_eq ! ( pool. available( ) , 0x1000 ) ;
174
- // Allocate aligned 0x110
174
+ // Allocate 0x110
175
175
assert_eq ! (
176
176
pool. allocate( 0x110 , 0x100 , AllocPolicy :: FirstMatch )
177
177
. unwrap( ) ,
178
178
RangeInclusive :: new( 0x1000 , 0x110F ) . unwrap( )
179
179
) ;
180
180
assert_eq ! ( pool. available( ) , 0x1000 - 0x110 ) ;
181
- // Allocate aligned 0x100
181
+ // Allocate 0x100
182
182
assert_eq ! (
183
183
pool. allocate( 0x100 , 0x100 , AllocPolicy :: FirstMatch )
184
184
. unwrap( ) ,
185
185
RangeInclusive :: new( 0x1200 , 0x12FF ) . unwrap( )
186
186
) ;
187
187
assert_eq ! ( pool. available( ) , 0x1000 - 0x110 - 0x100 ) ;
188
- // Allocate unaligned 0x10
188
+ // Allocate 0x10
189
189
assert_eq ! (
190
190
pool. allocate( 0x10 , 0x100 , AllocPolicy :: FirstMatch ) . unwrap( ) ,
191
191
RangeInclusive :: new( 0x1300 , 0x130F ) . unwrap( )
192
192
) ;
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 ) ;
194
200
}
195
201
196
202
#[ test]
0 commit comments