Skip to content

Commit

Permalink
Test coverage for unwrap_if_no_warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten committed Sep 16, 2024
1 parent e908c1c commit 85920d9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/tests/warnings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,30 @@ mod match_and_warnings {
let maw2 = maw1.clone();
assert_eq!(maw1, maw2);
}

#[test]
fn unwrap_if_no_warnings() {
let maw = MatchAndWarnings {
item: "xyz",
warnings: vec![],
};

let item = maw.unwrap_if_no_warnings();
assert_eq!(item, "xyz");
}

#[test]
#[should_panic]
fn unwrap_if_no_warnings_panic() {
let maw = MatchAndWarnings {
item: "xyz",
warnings: vec![Warning {
source: Span::new("abc"),
warning: WarningType::EmptyAttributeValue,
}],
};

let _ = maw.unwrap_if_no_warnings();
// There are warnings so this should panic.
}
}

0 comments on commit 85920d9

Please sign in to comment.