mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-12-01 03:15:33 +03:00
Fix Clippy lints in tests (#1563)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
This commit is contained in:
parent
e2d2f19fd0
commit
f064894e57
@ -322,7 +322,7 @@ mod test {
|
||||
use super::*;
|
||||
use smallvec::smallvec;
|
||||
|
||||
const LINE_END: &'static str = crate::DEFAULT_LINE_ENDING.as_str();
|
||||
const LINE_END: &str = crate::DEFAULT_LINE_ENDING.as_str();
|
||||
|
||||
fn differing_pairs() -> impl Iterator<Item = &'static (char, char)> {
|
||||
PAIRS.iter().filter(|(open, close)| open != close)
|
||||
@ -339,7 +339,7 @@ mod test {
|
||||
expected_doc: &Rope,
|
||||
expected_sel: &Selection,
|
||||
) {
|
||||
let trans = hook(&in_doc, &in_sel, ch).unwrap();
|
||||
let trans = hook(in_doc, in_sel, ch).unwrap();
|
||||
let mut actual_doc = in_doc.clone();
|
||||
assert!(trans.apply(&mut actual_doc));
|
||||
assert_eq!(expected_doc, &actual_doc);
|
||||
|
@ -91,12 +91,11 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_categorize() {
|
||||
const EOL_TEST_CASE: &'static str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
|
||||
const WORD_TEST_CASE: &'static str =
|
||||
"_hello_world_あいうえおー12345678901234567890";
|
||||
const PUNCTUATION_TEST_CASE: &'static str =
|
||||
const EOL_TEST_CASE: &str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
|
||||
const WORD_TEST_CASE: &str = "_hello_world_あいうえおー12345678901234567890";
|
||||
const PUNCTUATION_TEST_CASE: &str =
|
||||
"!\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~!”#$%&’()*+、。:;<=>?@「」^`{|}~";
|
||||
const WHITESPACE_TEST_CASE: &'static str = " ";
|
||||
const WHITESPACE_TEST_CASE: &str = " ";
|
||||
|
||||
for ch in EOL_TEST_CASE.chars() {
|
||||
assert_eq!(CharCategory::Eol, categorize_char(ch));
|
||||
|
@ -58,7 +58,7 @@ mod tests {
|
||||
let mut old = Rope::from(a);
|
||||
let new = Rope::from(b);
|
||||
compare_ropes(&old, &new).apply(&mut old);
|
||||
old.to_string() == new.to_string()
|
||||
old == new
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -448,8 +448,8 @@ mod test {
|
||||
change: crate::transaction::Change,
|
||||
instant: Instant,
|
||||
) {
|
||||
let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
|
||||
history.commit_revision_at_timestamp(&txn, &state, instant);
|
||||
let txn = Transaction::change(&state.doc, vec![change].into_iter());
|
||||
history.commit_revision_at_timestamp(&txn, state, instant);
|
||||
txn.apply(&mut state.doc);
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ where
|
||||
",
|
||||
);
|
||||
|
||||
let doc = Rope::from(doc);
|
||||
let doc = doc;
|
||||
use crate::diagnostic::Severity;
|
||||
use crate::syntax::{
|
||||
Configuration, IndentationConfiguration, LanguageConfiguration, Loader,
|
||||
@ -454,7 +454,7 @@ where
|
||||
|
||||
let language_config = loader.language_config_for_scope("source.rust").unwrap();
|
||||
let highlight_config = language_config.highlight_config(&[]).unwrap();
|
||||
let syntax = Syntax::new(&doc, highlight_config.clone(), std::sync::Arc::new(loader));
|
||||
let syntax = Syntax::new(&doc, highlight_config, std::sync::Arc::new(loader));
|
||||
let text = doc.slice(..);
|
||||
let tab_width = 4;
|
||||
|
||||
|
@ -250,7 +250,7 @@ mod line_ending_tests {
|
||||
assert_eq!(get_line_ending_of_str(&text[..6]), Some(LineEnding::CR));
|
||||
assert_eq!(get_line_ending_of_str(&text[..12]), Some(LineEnding::LF));
|
||||
assert_eq!(get_line_ending_of_str(&text[..17]), Some(LineEnding::Crlf));
|
||||
assert_eq!(get_line_ending_of_str(&text[..]), None);
|
||||
assert_eq!(get_line_ending_of_str(text), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -766,16 +766,16 @@ mod test {
|
||||
fn test_contains() {
|
||||
let range = Range::new(10, 12);
|
||||
|
||||
assert_eq!(range.contains(9), false);
|
||||
assert_eq!(range.contains(10), true);
|
||||
assert_eq!(range.contains(11), true);
|
||||
assert_eq!(range.contains(12), false);
|
||||
assert_eq!(range.contains(13), false);
|
||||
assert!(!range.contains(9));
|
||||
assert!(range.contains(10));
|
||||
assert!(range.contains(11));
|
||||
assert!(!range.contains(12));
|
||||
assert!(!range.contains(13));
|
||||
|
||||
let range = Range::new(9, 6);
|
||||
assert_eq!(range.contains(9), false);
|
||||
assert_eq!(range.contains(7), true);
|
||||
assert_eq!(range.contains(6), true);
|
||||
assert!(!range.contains(9));
|
||||
assert!(range.contains(7));
|
||||
assert!(range.contains(6));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -172,6 +172,7 @@ mod test {
|
||||
use ropey::Rope;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn check_find_nth_pair_pos(
|
||||
text: &str,
|
||||
cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
|
||||
|
@ -761,7 +761,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn combine_with_utf8() {
|
||||
const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
|
||||
const TEST_CASE: &str = "Hello, これはヘリックスエディターです!";
|
||||
|
||||
let empty = Rope::from("");
|
||||
let a = ChangeSet::new(&empty);
|
||||
|
@ -404,8 +404,8 @@ mod test {
|
||||
let text = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点\
|
||||
では、";
|
||||
let (word_wrapper, word_wrapper_width) =
|
||||
run_composer(Composer::WordWrapper { trim: true }, &text, width);
|
||||
let (line_truncator, _) = run_composer(Composer::LineTruncator, &text, width);
|
||||
run_composer(Composer::WordWrapper { trim: true }, text, width);
|
||||
let (line_truncator, _) = run_composer(Composer::LineTruncator, text, width);
|
||||
assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
|
||||
let wrapped = vec![
|
||||
"コンピュータ上で文字",
|
||||
|
@ -356,7 +356,7 @@ mod tests {
|
||||
let text = rope.slice(..);
|
||||
|
||||
assert_eq!(
|
||||
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
|
||||
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
|
||||
Some(0)
|
||||
);
|
||||
|
||||
@ -389,7 +389,7 @@ mod tests {
|
||||
let text = rope.slice(..);
|
||||
|
||||
assert_eq!(
|
||||
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
|
||||
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
|
||||
Some(0)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user