Skip to content

Commit

Permalink
fix tests, clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
CptPotato committed Jan 23, 2023
1 parent cacf696 commit 8dc07ca
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion helix-core/src/line_ending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down
2 changes: 1 addition & 1 deletion helix-term/tests/test/auto_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = &'static (char, char)> {
DEFAULT_PAIRS.iter().filter(|(open, close)| open != close)
Expand Down
2 changes: 1 addition & 1 deletion helix-term/tests/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn temp_file_with_contents<S: AsRef<str>>(
/// 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
Expand Down
5 changes: 3 additions & 2 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,10 @@ mod test {

#[test]
fn test_line_ending() {
let line_ending = LineEnding::native();
assert_eq!(
Document::default().text().to_string(),
DEFAULT_LINE_ENDING.as_str()
Document::new(line_ending).text().to_string(),
line_ending.as_str()
);
}

Expand Down
12 changes: 6 additions & 6 deletions helix-view/src/gutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ mod tests {
use crate::editor::{GutterConfig, GutterLineNumbersConfig};
use crate::graphics::Rect;
use crate::DocumentId;
use helix_core::Rope;
use helix_core::{LineEnding, Rope};

#[test]
fn test_default_gutter_widths() {
let mut view = View::new(DocumentId::default(), GutterConfig::default());
view.area = Rect::new(40, 40, 40, 40);

let rope = Rope::from_str("abc\n\tdef");
let doc = Document::from(rope, None);
let doc = Document::from(rope, None, LineEnding::native());

assert_eq!(view.gutters.layout.len(), 5);
assert_eq!(view.gutters.layout[0].width(&view, &doc), 1);
Expand All @@ -325,7 +325,7 @@ mod tests {
view.area = Rect::new(40, 40, 40, 40);

let rope = Rope::from_str("abc\n\tdef");
let doc = Document::from(rope, None);
let doc = Document::from(rope, None, LineEnding::native());

assert_eq!(view.gutters.layout.len(), 1);
assert_eq!(view.gutters.layout[0].width(&view, &doc), 1);
Expand All @@ -339,7 +339,7 @@ mod tests {
view.area = Rect::new(40, 40, 40, 40);

let rope = Rope::from_str("abc\n\tdef");
let doc = Document::from(rope, None);
let doc = Document::from(rope, None, LineEnding::native());

assert_eq!(view.gutters.layout.len(), 2);
assert_eq!(view.gutters.layout[0].width(&view, &doc), 1);
Expand All @@ -357,10 +357,10 @@ mod tests {
view.area = Rect::new(40, 40, 40, 40);

let rope = Rope::from_str("a\nb");
let doc_short = Document::from(rope, None);
let doc_short = Document::from(rope, None, LineEnding::native());

let rope = Rope::from_str("a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np");
let doc_long = Document::from(rope, None);
let doc_long = Document::from(rope, None, LineEnding::native());

assert_eq!(view.gutters.layout.len(), 2);
assert_eq!(view.gutters.layout[1].width(&view, &doc_short), 1);
Expand Down

0 comments on commit 8dc07ca

Please sign in to comment.