diff --git a/tests/fixtures/expand/with-spaces.txt b/tests/fixtures/expand/with-spaces.txt new file mode 100644 index 000000000..235ad8cc7 --- /dev/null +++ b/tests/fixtures/expand/with-spaces.txt @@ -0,0 +1,6 @@ +// !note: file contains significant whitespace +// * indentation uses characters +int foo() { + // with spaces + return 0; +} diff --git a/tests/fixtures/expand/with-tab.txt b/tests/fixtures/expand/with-tab.txt new file mode 100644 index 000000000..e6fd89f55 --- /dev/null +++ b/tests/fixtures/expand/with-tab.txt @@ -0,0 +1,6 @@ +// !note: file contains significant whitespace +// * indentation uses characters +int main() { + // with tabs + return 0; +} diff --git a/tests/fixtures/expand/with-trailing-tab.txt b/tests/fixtures/expand/with-trailing-tab.txt new file mode 100644 index 000000000..dfb2c03dd --- /dev/null +++ b/tests/fixtures/expand/with-trailing-tab.txt @@ -0,0 +1,7 @@ +// !note: file contains significant whitespace +// * indentation uses characters +int main() { + // * next line has both a leading & trailing tab + // with tabs=> + return 0; +} diff --git a/tests/test_expand.rs b/tests/test_expand.rs new file mode 100644 index 000000000..a8474e9b3 --- /dev/null +++ b/tests/test_expand.rs @@ -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")); +} diff --git a/tests/tests.rs b/tests/tests.rs index ed1271744..432caf63f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -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;