1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Test the rsure API for save and load.
/*
extern crate rsure;
extern crate tempdir;
use rsure::{stdout_visitor, SureTree, TreeCompare};
use tempdir::TempDir;
// Test that the API is usable. Currently, the output only generates a
// report to stdout, and doesn't return any information to the caller, so
// we can only test that the calls work. If you run the test with
// "--nocapture", it should show the addition of the surefile at the end.
#[test]
fn save_and_load() {
let tmp = TempDir::new("rsure").unwrap();
let tree = rsure::scan_fs(tmp.path()).unwrap();
// First surefile.
let sfile = tmp.path().join("surefile.dat.gz");
// Save it to a file.
tree.save(&sfile).unwrap();
// Load it back in.
let t2 = SureTree::load(&sfile).unwrap();
t2.compare_from(&mut stdout_visitor(), &tree, &sfile);
// Rescan (should catch the newly added surefile).
let t3 = rsure::scan_fs(tmp.path()).unwrap();
t3.compare_from(&mut stdout_visitor(), &t2, tmp.path());
}
// Test writing to a block.
#[test]
fn save_writer() {
let tmp = TempDir::new("rsure").unwrap();
let t1 = rsure::scan_fs(tmp.path()).unwrap();
let mut sf1 = vec![];
t1.save_to(&mut sf1).unwrap();
println!("Wrote {} bytes", sf1.len());
let t2 = SureTree::load_from(&sf1[..]).unwrap();
t2.compare_from(&mut stdout_visitor(), &t1, tmp.path());
}
*/