mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 01:19:25 +01:00
7d6b23ee2f
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
50 lines
1.2 KiB
Rust
50 lines
1.2 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn to_column() {
|
|
Playground::setup("split_column_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![
|
|
FileWithContentToBeTrimmed(
|
|
"sample.txt",
|
|
r#"
|
|
importer,shipper,tariff_item,name,origin
|
|
"#,
|
|
),
|
|
FileWithContentToBeTrimmed(
|
|
"sample2.txt",
|
|
r#"
|
|
importer , shipper , tariff_item , name , origin
|
|
"#,
|
|
),
|
|
]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.txt
|
|
| lines
|
|
| str trim
|
|
| split column ","
|
|
| get column2
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("shipper"));
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r"
|
|
open sample2.txt
|
|
| lines
|
|
| str trim
|
|
| split column -r '\s*,\s*'
|
|
| get column2
|
|
"
|
|
));
|
|
|
|
assert!(actual.out.contains("shipper"));
|
|
})
|
|
}
|