1
1
use std::path::{Path, PathBuf};
2

            
3
use interner::shared::{PathPool, SharedPath};
4

            
5
1
fn main() {
6
1
    let pool = PathPool::default();
7
1

            
8
1
    // Get a value from the pool.
9
1
    let a = pool.get(PathBuf::from("a"));
10
1
    // Request it again.
11
1
    let a_again = pool.get(Path::new("a"));
12
1

            
13
1
    // Verify that the paths are the same underlying allocation.
14
1
    assert!(SharedPath::ptr_eq(&a, &a_again));
15

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

            
23
1
#[test]
24
1
fn runs() {
25
1
    main();
26
1
}