| 385 | |
| 386 | #[test] |
| 387 | fn basic_alloc_get_free() { |
| 388 | let mut slab = SlabAllocator::new(); |
| 389 | |
| 390 | // Small value (fits in 64B tier). |
| 391 | let (h1, l1) = slab.alloc(b"hello"); |
| 392 | assert_eq!(slab.get(h1, l1), b"hello"); |
| 393 | |
| 394 | // Medium value (fits in 256B tier). |
| 395 | let data = vec![0xAB; 200]; |
| 396 | let (h2, l2) = slab.alloc(&data); |
| 397 | assert_eq!(slab.get(h2, l2), &data); |
| 398 | |
| 399 | // Free and realloc. |
| 400 | slab.free(h1, l1); |
| 401 | let (h3, l3) = slab.alloc(b"world"); |
| 402 | assert_eq!(slab.get(h3, l3), b"world"); |
| 403 | // Should reuse the freed slot. |
| 404 | assert_eq!(h3, h1); |
| 405 | } |
| 406 | |
| 407 | #[test] |
| 408 | fn large_object_fallback() { |