1
1
use interner::shared::{BufferPool, SharedBuffer};
2

            
3
1
fn main() {
4
1
    let pool = BufferPool::default();
5
1

            
6
1
    // Get a value from the pool.
7
1
    let a = pool.get(vec![b'a']);
8
1
    // Request it again.
9
1
    let a_again = pool.get(&b"a"[..]);
10
1

            
11
1
    // Verify that the strings are the same underlying allocation.
12
1
    assert!(SharedBuffer::ptr_eq(&a, &a_again));
13

            
14
    // Once all of our instances are dropped, the value should be freed.
15
1
    drop(a);
16
1
    drop(a_again);
17
1
    let all: Vec<SharedBuffer> = pool.pooled();
18
1
    assert!(all.is_empty());
19
1
}
20

            
21
1
#[test]
22
1
fn runs() {
23
1
    main();
24
1
}