Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 821a370

Browse files
author
Ruben Schmidmeister
committed
Add tests to cover more edge cases
1 parent 1f09d94 commit 821a370

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/formatting/newline_style.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,33 @@ mod tests {
172172
);
173173
}
174174

175+
#[test]
176+
fn applying_unix_newlines_changes_nothing_for_unix_newlines() {
177+
let formatted_text = "One\nTwo\nThree";
178+
test_newlines_are_applied_correctly(formatted_text, formatted_text, NewlineStyle::Unix);
179+
}
180+
181+
#[test]
182+
fn applies_unix_newlines_to_string_with_unix_and_windows_newlines() {
183+
test_newlines_are_applied_correctly(
184+
"One\r\nTwo\r\nThree\nFour",
185+
"One\nTwo\nThree\nFour",
186+
NewlineStyle::Unix,
187+
);
188+
}
189+
190+
#[test]
191+
fn applies_windows_newlines_to_string_with_unix_and_windows_newlines() {
192+
test_newlines_are_applied_correctly(
193+
"One\nTwo\nThree\r\nFour",
194+
"One\r\nTwo\r\nThree\r\nFour",
195+
NewlineStyle::Windows,
196+
);
197+
}
198+
175199
#[test]
176200
fn applying_windows_newlines_changes_nothing_for_windows_newlines() {
177201
let formatted_text = "One\r\nTwo\r\nThree";
178-
179202
test_newlines_are_applied_correctly(formatted_text, formatted_text, NewlineStyle::Windows);
180203
}
181204

0 commit comments

Comments
 (0)