mirror of
https://github.com/uutils/coreutils
synced 2024-07-23 19:04:18 +00:00
test(expand): Add some tests for expand (#1505)
This commit is contained in:
parent
0ca5132a06
commit
601690b079
6
tests/fixtures/expand/with-spaces.txt
vendored
Normal file
6
tests/fixtures/expand/with-spaces.txt
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
// !note: file contains significant whitespace
|
||||
// * indentation uses <SPACE> characters
|
||||
int foo() {
|
||||
// with spaces
|
||||
return 0;
|
||||
}
|
6
tests/fixtures/expand/with-tab.txt
vendored
Normal file
6
tests/fixtures/expand/with-tab.txt
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
// !note: file contains significant whitespace
|
||||
// * indentation uses <TAB> characters
|
||||
int main() {
|
||||
// with tabs
|
||||
return 0;
|
||||
}
|
7
tests/fixtures/expand/with-trailing-tab.txt
vendored
Normal file
7
tests/fixtures/expand/with-trailing-tab.txt
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
// !note: file contains significant whitespace
|
||||
// * indentation uses <TAB> characters
|
||||
int main() {
|
||||
// * next line has both a leading & trailing tab
|
||||
// with tabs=>
|
||||
return 0;
|
||||
}
|
48
tests/test_expand.rs
Normal file
48
tests/test_expand.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
use common::util::*;
|
||||
|
||||
#[test]
|
||||
fn test_with_tab() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let result = ucmd.arg("with-tab.txt").run();
|
||||
assert!(result.success);
|
||||
assert!(result.stdout.contains(" "));
|
||||
assert!(!result.stdout.contains("\t"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_trailing_tab() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let result = ucmd.arg("with-trailing-tab.txt").run();
|
||||
assert!(result.success);
|
||||
assert!(result.stdout.contains("with tabs=> "));
|
||||
assert!(!result.stdout.contains("\t"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_trailing_tab_i() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let result = ucmd.arg("with-trailing-tab.txt").arg("-i").run();
|
||||
assert!(result.success);
|
||||
assert!(result.stdout.contains(" // with tabs=>\t"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_tab_size() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let result = ucmd.arg("with-tab.txt").arg("--tabs=10").run();
|
||||
assert!(result.success);
|
||||
assert!(result.stdout.contains(" "));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_space() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let result = ucmd.arg("with-spaces.txt").run();
|
||||
assert!(result.success);
|
||||
assert!(result.stdout.contains(" return"));
|
||||
}
|
|
@ -62,6 +62,7 @@ generic! {
|
|||
"du", test_du;
|
||||
"echo", test_echo;
|
||||
"env", test_env;
|
||||
"expand", test_expand;
|
||||
"expr", test_expr;
|
||||
"factor", test_factor;
|
||||
"false", test_false;
|
||||
|
|
Loading…
Reference in a new issue