Split auto_detect tests into seperate fns
@@ -79,25 +79,32 @@ mod tests {
use super::*;
#[test]
- fn test_newline_style_auto_detect() {
- let lf = "One\nTwo\nThree";
- let crlf = "One\r\nTwo\r\nThree";
- let none = "One Two Three";
-
- assert_eq!(EffectiveNewlineStyle::Unix, auto_detect_newline_style(lf));
+ fn auto_detects_unix_newlines() {
assert_eq!(
- EffectiveNewlineStyle::Windows,
- auto_detect_newline_style(crlf)
+ EffectiveNewlineStyle::Unix,
+ auto_detect_newline_style("One\nTwo\nThree")
);
+ }
- if cfg!(windows) {
+ #[test]
+ fn auto_detects_windows_newlines() {
assert_eq!(
EffectiveNewlineStyle::Windows,
- auto_detect_newline_style(none)
+ auto_detect_newline_style("One\r\nTwo\r\nThree")
);
- } else {
- assert_eq!(EffectiveNewlineStyle::Unix, auto_detect_newline_style(none));
}
+
+ #[test]
+ fn falls_back_to_native_newlines_if_no_newlines_are_found() {
+ let expected_newline_style = if cfg!(windows) {
+ EffectiveNewlineStyle::Windows
+ } else {
+ EffectiveNewlineStyle::Unix
+ };
+ assert_eq!(
+ expected_newline_style,
+ auto_detect_newline_style("One Two Three")
+ );
}
#[test]
