From 796ee834c1e31ead4c5479bf2827a4339c5d61d1 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Wed, 28 Jun 2023 22:50:34 +0200 Subject: [PATCH] test that running `nufmt` twice produces the same output (#40) original discussion on Discord: https://discord.com/channels/601130461678272522/1117921521520873623/1123167419951763466 cc/ @AucaCoyan --- src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6a98627..660f2f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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]