MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_resize_with_pool

Function test_resize_with_pool

arrow-buffer/src/buffer/mutable.rs:1487–1511  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1485
1486 #[test]
1487 fn test_resize_with_pool() {
1488 let pool = TrackingMemoryPool::default();
1489 let mut buffer = MutableBuffer::with_capacity(100);
1490 buffer.claim(&pool);
1491
1492 // Initial state
1493 assert_eq!(buffer.len(), 0);
1494 assert_eq!(pool.used(), 128);
1495
1496 // Resize to increase length
1497 buffer.resize(50, 1);
1498 assert_eq!(buffer.len(), 50);
1499 assert_eq!(pool.used(), 50);
1500
1501 // Resize to increase length beyond capacity
1502 buffer.resize(150, 1);
1503 assert_eq!(buffer.len(), 150);
1504 assert_eq!(buffer.capacity(), 256);
1505 assert_eq!(pool.used(), 150);
1506
1507 // Resize to decrease length
1508 buffer.resize(30, 1);
1509 assert_eq!(buffer.len(), 30);
1510 assert_eq!(pool.used(), 30);
1511 }
1512
1513 #[test]
1514 fn test_buffer_lifecycle_with_pool() {

Callers

nothing calls this directly

Calls 3

defaultFunction · 0.85
claimMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected