Skip to content

Commit

Permalink
tests: add test on par coverage ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
noamteyssier committed May 2, 2024
1 parent 45ec136 commit 49ae97c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,51 @@ mod testing {
Ok(())
}

#[test]
fn test_coverage_mt() -> Result<()> {
let a = "tests/datasets/coverage/coverage_a.bed";
let b = "tests/datasets/coverage/coverage_b.bed";

let mut cmd = Command::cargo_bin("gia")?;
let output = cmd
.arg("coverage")
.arg("-a")
.arg(a)
.arg("-b")
.arg(b)
.arg("-@")
.arg("4")
.output()?;
println!("{:?}", output);
let num_intervals = output.stdout.split(|&c| c == b'\n').count() - 1;
assert_eq!(num_intervals, 10);

let num_fields = output
.stdout
.split(|&c| c == b'\n')
.next()
.unwrap()
.split(|&c| c == b'\t')
.count();
assert_eq!(num_fields, 4);

let expected = vec![
(1, 72, 222, 4),
(1, 257, 407, 1),
(1, 268, 418, 1),
(1, 467, 617, 1),
(1, 819, 969, 1),
(2, 174, 324, 2),
(2, 587, 737, 1),
(3, 395, 545, 0),
(3, 554, 704, 0),
(3, 653, 803, 0),
];
let expected_str = build_expected_str(&expected);
assert_eq!(output.stdout, expected_str.as_bytes());
Ok(())
}

#[test]
fn test_coverage_bed3_bed3() -> Result<()> {
let a = "tests/datasets/coverage/coverage_a.bed";
Expand Down

0 comments on commit 49ae97c

Please sign in to comment.