Skip to content

Commit

Permalink
trim carriage return (\r) in print_sparse_cached_coverage_taker too
Browse files Browse the repository at this point in the history
  • Loading branch information
AroneyS committed Jun 11, 2024
1 parent a80d4eb commit 42826ef
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/coverage_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub fn print_sparse_cached_coverage_taker(
"{}\t{}",
stoit,
match &entry_names[*entry_i] {
Some(s) => s,
Some(s) => s.trim_end_matches('\r'),
None => {
error!("Didn't find entry name string as expected");
process::exit(1);
Expand Down Expand Up @@ -669,4 +669,34 @@ mod tests {
contig2\t1025\t12.1\t2.1\t2.2\t22.1\t22.2\n",
std::fs::read_to_string(tf.path()).unwrap());
}

#[test]
fn test_sparse_cached_printer_hello_world() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_sparse_cached_coverage_taker(&c, &mut stream, None, &vec![], None, None);
assert_eq!(
"stoit1\tcontig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}

#[test]
fn test_sparse_cached_printer_newline() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1\r");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_sparse_cached_coverage_taker(&c, &mut stream, None, &vec![], None, None);
assert_eq!(
"stoit1\tcontig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}
}

0 comments on commit 42826ef

Please sign in to comment.