Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Nov 3, 2024
1 parent 321ae92 commit dc069b7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/core/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ mod test {
assert_eq!(cl.len(), 0);
}

// lock down 'into_iter' implementation :sweat_smile:
// lock down 'iter' implementation :sweat_smile:
#[test]
fn collection_iter() {
// load test sigs
Expand All @@ -388,7 +388,28 @@ mod test {
// all sigs should remain
assert_eq!(cl.len(), 4);

let _v: Vec<(Idx, &Record)> = cl.iter().into_iter().collect();
let _i = cl.len();
}

// lock down 'into_iter' implementation :sweat_smile:
#[test]
fn collection_into_iter() {
// load test sigs
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// four num=500 sigs
filename.push("../../tests/test-data/genome-s11.fa.gz.sig");
let file = File::open(filename).unwrap();
let reader = BufReader::new(file);
let sigs: Vec<Signature> = serde_json::from_reader(reader).expect("Loading error");
assert_eq!(sigs.len(), 4);
// load sigs into collection + select compatible signatures
let cl = Collection::from_sigs(sigs).unwrap();
// all sigs should remain
assert_eq!(cl.len(), 4);

let _v: Vec<(Idx, Record)> = cl.into_iter().into_iter().collect();
// let _i = cl.len(); // cl is consumed w/into_iter.
}

#[test]
Expand Down

0 comments on commit dc069b7

Please sign in to comment.