Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegenes committed Dec 16, 2024
1 parent b20479c commit e5ea8af
Showing 1 changed file with 86 additions and 1 deletion.
87 changes: 86 additions & 1 deletion src/core/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,6 @@ impl TryInto<KmerMinHash> for Signature {
#[cfg(test)]
mod test {

use core::num;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::PathBuf;
Expand Down Expand Up @@ -1441,6 +1440,83 @@ mod test {
assert_eq!(frame.rc(), b"ACGACT".as_slice());
}

#[test]
fn test_fw_dna() {
let dna_frame = ReadingFrame::DNA {
fw: b"ATCG".to_vec(),
rc: b"CGAT".to_vec(),
len: 4,
};
assert_eq!(dna_frame.fw(), b"ATCG");
}

#[test]
fn test_rc_dna() {
let dna_frame = ReadingFrame::DNA {
fw: b"ATCG".to_vec(),
rc: b"CGAT".to_vec(),
len: 4,
};
assert_eq!(dna_frame.rc(), b"CGAT");
}

#[test]
fn test_length_dna() {
let dna_frame = ReadingFrame::DNA {
fw: b"ATCG".to_vec(),
rc: b"CGAT".to_vec(),
len: 4,
};
assert_eq!(dna_frame.length(), 4);
}

#[test]
fn test_frame_type_dna() {
let dna_frame = ReadingFrame::DNA {
fw: b"ATCG".to_vec(),
rc: b"CGAT".to_vec(),
len: 4,
};
assert_eq!(dna_frame.frame_type(), "DNA");
}

#[test]
fn test_fw_protein() {
let protein_frame = ReadingFrame::Protein {
fw: b"MVHL".to_vec(),
len: 4,
};
assert_eq!(protein_frame.fw(), b"MVHL");
}

#[test]
#[should_panic(expected = "Reverse complement is only available for DNA frames")]
fn test_rc_protein_panics() {
let protein_frame = ReadingFrame::Protein {
fw: b"MVHL".to_vec(),
len: 4,
};
protein_frame.rc();
}

#[test]
fn test_length_protein() {
let protein_frame = ReadingFrame::Protein {
fw: b"MVHL".to_vec(),
len: 4,
};
assert_eq!(protein_frame.length(), 4);
}

#[test]
fn test_frame_type_protein() {
let protein_frame = ReadingFrame::Protein {
fw: b"MVHL".to_vec(),
len: 4,
};
assert_eq!(protein_frame.frame_type(), "Protein");
}

#[test]
fn test_seqtohashes_frames_dna() {
let sequence = b"AGTCGT";
Expand Down Expand Up @@ -1556,6 +1632,15 @@ mod test {
assert_eq!(frames[5].fw(), b"LDD".as_slice());
}

#[test]
#[should_panic(expected = "Frame number must be 0, 1, or 2")]
fn test_readingframe_translate() {
let sequence = b"AGTCGT";
let frame_start = 3; // four frames but translate can only

ReadingFrame::new_translated(sequence, frame_start, false, false);
}

#[test]
#[should_panic(expected = "Skipmer frame number must be < n")]
fn test_readingframe_skipmer() {
Expand Down

0 comments on commit e5ea8af

Please sign in to comment.