mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
test(expand): Add some tests for expand (#1505)
This commit is contained in:
parent
0ca5132a06
commit
601690b079
5 changed files with 68 additions and 0 deletions
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;
|
"du", test_du;
|
||||||
"echo", test_echo;
|
"echo", test_echo;
|
||||||
"env", test_env;
|
"env", test_env;
|
||||||
|
"expand", test_expand;
|
||||||
"expr", test_expr;
|
"expr", test_expr;
|
||||||
"factor", test_factor;
|
"factor", test_factor;
|
||||||
"false", test_false;
|
"false", test_false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue