aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-04-29 20:27:35 +0000
committerSkyler Hawthorne2022-06-19 03:57:47 +0000
commitef8fe5a5ce536c65f34e479db79b94c8435aa3b2 (patch)
tree3ceb1adaf98d6cae9198497e16e56eddba61869a /helix-term/tests
parent28e94fb2613fbedeef56c1bc6e21830277bb35bb (diff)
use system's appropriate line ending
Diffstat (limited to 'helix-term/tests')
-rw-r--r--helix-term/tests/integration/auto_indent.rs7
-rw-r--r--helix-term/tests/integration/helpers.rs17
-rw-r--r--helix-term/tests/integration/write.rs5
3 files changed, 25 insertions, 4 deletions
diff --git a/helix-term/tests/integration/auto_indent.rs b/helix-term/tests/integration/auto_indent.rs
index 74d1ac58..8933cb6a 100644
--- a/helix-term/tests/integration/auto_indent.rs
+++ b/helix-term/tests/integration/auto_indent.rs
@@ -10,13 +10,14 @@ async fn auto_indent_c() -> anyhow::Result<()> {
Config::default(),
// switches to append mode?
(
- "void foo() {#[|}]#\n",
+ helpers::platform_line("void foo() {#[|}]#").as_ref(),
"i<ret><esc>",
- indoc! {"\
+ helpers::platform_line(indoc! {"\
void foo() {
#[|\n]#\
}
- "},
+ "})
+ .as_ref(),
),
)
.await?;
diff --git a/helix-term/tests/integration/helpers.rs b/helix-term/tests/integration/helpers.rs
index 2a542404..706e1afb 100644
--- a/helix-term/tests/integration/helpers.rs
+++ b/helix-term/tests/integration/helpers.rs
@@ -138,3 +138,20 @@ pub fn temp_file_with_contents<S: AsRef<str>>(
temp_file.as_file_mut().sync_all()?;
Ok(temp_file)
}
+
+/// Replaces all LF chars with the system's appropriate line feed
+/// 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();
+
+ // we can assume that the source files in this code base will always
+ // be LF, so indoc strings will always insert LF
+ let mut output = input.replace("\n", line_end);
+
+ if !output.ends_with(line_end) {
+ output.push_str(line_end);
+ }
+
+ output
+}
diff --git a/helix-term/tests/integration/write.rs b/helix-term/tests/integration/write.rs
index 4f8f0eb5..06af9dd8 100644
--- a/helix-term/tests/integration/write.rs
+++ b/helix-term/tests/integration/write.rs
@@ -31,7 +31,10 @@ async fn test_write() -> anyhow::Result<()> {
let mut file_content = String::new();
file.as_file_mut().read_to_string(&mut file_content)?;
- assert_eq!("i can eat glass, it will not hurt me\n", file_content);
+ assert_eq!(
+ helpers::platform_line("i can eat glass, it will not hurt me"),
+ file_content
+ );
Ok(())
}