Skip to content

Commit

Permalink
test that running nufmt twice produces the same output (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Jun 28, 2023
1 parent 5ed97a6 commit 796ee83
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ pub fn format_string(input_string: &String, config: &Config) -> String {
mod test {
use super::*;

/// test that
/// 1. formatting the input gives the expected result
/// 2. formatting the output of `nufmt` a second time does not change the content
fn run_test(input: &str, expected: &str) {
assert_eq!(
expected.to_string(),
format_string(&input.to_string(), &Config::default())
);
let formatted = format_string(&input.to_string(), &Config::default());

assert_eq!(expected.to_string(), formatted);
assert_eq!(formatted, format_string(&formatted, &Config::default()));
}

#[test]
Expand Down

0 comments on commit 796ee83

Please sign in to comment.