Skip to content

Commit

Permalink
Merge pull request #4 from Apricot-S/test/output-1-case
Browse files Browse the repository at this point in the history
test: stop at the first mismatch
  • Loading branch information
Apricot-S authored Sep 23, 2024
2 parents d477f34 + 9592fc7 commit ff29cb2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ mod tests {

fn verify_correctness(length: usize) -> bool {
let enumerator = HandEnumerator::new(length).unwrap();
let mut all_match = true;
let file_name = format!("./mismatches_{}.txt", length);
let file_name = format!("./mismatch_{}.txt", length);

enumerator.into_iter().for_each(|hand| {
let result = enumerator.into_iter().try_for_each(|hand| {
let result_nyanten =
unsafe { calculateReplacementNumber(hand.as_ptr(), hand.as_ptr().add(34)) };
let result_xiangting = calculate_replacement_number(&hand, &None).unwrap();

if result_xiangting != result_nyanten {
all_match = false;

let mut file = OpenOptions::new()
.append(true)
.create(true)
Expand All @@ -38,10 +35,14 @@ mod tests {
hand, result_nyanten, result_xiangting,
)
.unwrap();

return Err(());
}

Ok(())
});

all_match
result.is_ok()
}

#[test]
Expand Down

0 comments on commit ff29cb2

Please sign in to comment.