From d2645002e3aa757684572b73058ce270f2be80a4 Mon Sep 17 00:00:00 2001 From: CptPotato <3957610+CptPotato@users.noreply.github.com> Date: Mon, 23 Jan 2023 21:28:57 +0100 Subject: [PATCH] fix tests, clippy lints --- helix-core/src/line_ending.rs | 2 +- helix-term/tests/test/auto_pairs.rs | 2 +- helix-term/tests/test/helpers.rs | 2 +- helix-view/src/document.rs | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs index 8c33fcdbbd1c3..b534e179ac4a1 100644 --- a/helix-core/src/line_ending.rs +++ b/helix-core/src/line_ending.rs @@ -112,7 +112,7 @@ impl LineEnding { /// /// [`LineEnding::Crlf`] on Windows, otherwise [`LineEnding::LF`]. #[inline] - pub fn native() -> Self { + pub const fn native() -> Self { #[cfg(target_os = "windows")] return LineEnding::Crlf; #[cfg(not(target_os = "windows"))] diff --git a/helix-term/tests/test/auto_pairs.rs b/helix-term/tests/test/auto_pairs.rs index e18c71195fb49..40d687f3e18a8 100644 --- a/helix-term/tests/test/auto_pairs.rs +++ b/helix-term/tests/test/auto_pairs.rs @@ -2,7 +2,7 @@ use helix_core::{auto_pairs::DEFAULT_PAIRS, hashmap}; use super::*; -const LINE_END: &str = helix_core::DEFAULT_LINE_ENDING.as_str(); +const LINE_END: &str = helix_core::LineEnding::native().as_str(); fn differing_pairs() -> impl Iterator { DEFAULT_PAIRS.iter().filter(|(open, close)| open != close) diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs index a0f3a32e4cba3..406d817e6d064 100644 --- a/helix-term/tests/test/helpers.rs +++ b/helix-term/tests/test/helpers.rs @@ -230,7 +230,7 @@ pub fn temp_file_with_contents>( /// character, and if one doesn't exist already, appends the system's /// appropriate line ending to the end of a string. pub fn platform_line(input: &str) -> String { - let line_end = helix_core::DEFAULT_LINE_ENDING.as_str(); + let line_end = helix_core::LineEnding::native().as_str(); // we can assume that the source files in this code base will always // be LF, so indoc strings will always insert LF diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index f0cf597916611..e11a47a7dfe2a 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1391,10 +1391,12 @@ mod test { #[test] fn test_line_ending() { - assert_eq!( - Document::default().text().to_string(), - DEFAULT_LINE_ENDING.as_str() - ); + for line_ending in [LineEnding::LF, LineEnding::Crlf] { + assert_eq!( + Document::new(line_ending).text().to_string(), + line_ending.as_str() + ); + } } macro_rules! decode {