Simplify rawstrings in tests (#10180)

Inspired by
https://rust-lang.github.io/rust-clippy/master/index.html#/needless_raw_string_hashes

Ran `cargo +stable clippy --workspace --all-targets`

Fixed manually as I ran into a false positive along the lines of:
https://github.com/rust-lang/rust-clippy/issues/11068

Also collapse one set of single line tests.

Work for #8670
This commit is contained in:
Stefan Holderbach 2023-09-01 00:08:27 +02:00 committed by GitHub
parent e68ae4c8d1
commit 7d6b23ee2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 19 deletions

View File

@ -1,23 +1,15 @@
use nu_test_support::{nu, pipeline}; use nu_test_support::nu;
#[test] #[test]
fn test_ansi_shows_error_on_escape() { fn test_ansi_shows_error_on_escape() {
let actual = nu!(pipeline( let actual = nu!(r"ansi -e \");
r#"
ansi -e \
"#
));
assert!(actual.err.contains("no need for escape characters")) assert!(actual.err.contains("no need for escape characters"))
} }
#[test] #[test]
fn test_ansi_list_outputs_table() { fn test_ansi_list_outputs_table() {
let actual = nu!(pipeline( let actual = nu!("ansi --list | length");
r#"
ansi --list | length
"#
));
assert_eq!(actual.out, "424"); assert_eq!(actual.out, "424");
} }

View File

@ -35,13 +35,13 @@ fn to_column() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r"
open sample2.txt open sample2.txt
| lines | lines
| str trim | str trim
| split column -r '\s*,\s*' | split column -r '\s*,\s*'
| get column2 | get column2
"# "
)); ));
assert!(actual.out.contains("shipper")); assert!(actual.out.contains("shipper"));

View File

@ -35,13 +35,13 @@ fn to_row() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r"
open sample2.txt open sample2.txt
| lines | lines
| str trim | str trim
| split row -r '\s*,\s*' | split row -r '\s*,\s*'
| length | length
"# "
)); ));
assert!(actual.out.contains('5')); assert!(actual.out.contains('5'));

View File

@ -254,12 +254,12 @@ fn from_csv_text_with_custom_escapes_to_table() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r"
open los_tres_caballeros.txt open los_tres_caballeros.txt
| from csv --escape '\' | from csv --escape '\'
| first | first
| get first_name | get first_name
"# "
)); ));
assert_eq!(actual.out, "And\"rés"); assert_eq!(actual.out, "And\"rés");

View File

@ -177,12 +177,12 @@ fn from_tsv_text_with_custom_escapes_to_table() {
let actual = nu!( let actual = nu!(
cwd: dirs.test(), pipeline( cwd: dirs.test(), pipeline(
r#" r"
open los_tres_caballeros.txt open los_tres_caballeros.txt
| from tsv --escape '\' | from tsv --escape '\'
| first | first
| get first_name | get first_name
"# "
)); ));
assert_eq!(actual.out, "And\"rés"); assert_eq!(actual.out, "And\"rés");