Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Jun 24, 2019
1 parent 4262210 commit ef80916
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rls/src/actions/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ mod tests {
use super::*;
use crate::config::FmtConfig;
use lsp_types::{Position, Range, TextEdit};
use rustfmt_nightly::FileLines;
use std::str::FromStr;

#[test]
fn calc_text_edits() {
Expand Down Expand Up @@ -247,4 +249,20 @@ mod tests {
vec![(0, 0, 1, 0, "struct Upper;\n"), (2, 0, 3, 0, "struct Lower;\n")],
);
}

#[test]
fn no_empty_file_lines() {
let config_with_lines = {
let mut config = Config::default();
config.set().file_lines(
FileLines::from_str(r#"[{ "file": "stdin", "range": [0, 5] }]"#).unwrap(),
);
config
};
let args = rustfmt_args(&config_with_lines, Path::new("dummy"));
assert!(args.join(" ").find("--file-lines").is_some());

let args = rustfmt_args(&Config::default(), Path::new("dummy"));
assert_eq!(args.join(" ").find("--file-lines"), None);
}
}

0 comments on commit ef80916

Please sign in to comment.