From cf399faad26f863a4eb00243a56d22485b6da65d Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Sat, 12 Dec 2015 16:24:48 -0500 Subject: [PATCH] Add initial tests for default values --- Makefile | 1 + tests/fixtures/tail/foobar.txt | 11 +++++++++ .../tail/foobar_single_default.expected | 10 ++++++++ .../tail/foobar_stdin_default.expected | 10 ++++++++ tests/tail.rs | 23 +++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 tests/fixtures/tail/foobar.txt create mode 100644 tests/fixtures/tail/foobar_single_default.expected create mode 100644 tests/fixtures/tail/foobar_stdin_default.expected create mode 100644 tests/tail.rs diff --git a/Makefile b/Makefile index 3b26cab06..c36fbac71 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,7 @@ TEST_PROGS := \ stdbuf \ sum \ tac \ + tail \ test \ touch \ tr \ diff --git a/tests/fixtures/tail/foobar.txt b/tests/fixtures/tail/foobar.txt new file mode 100644 index 000000000..32233d4a7 --- /dev/null +++ b/tests/fixtures/tail/foobar.txt @@ -0,0 +1,11 @@ +baz +foo +bar +foo +bar +foo +bar +foo +bar +foo +bar diff --git a/tests/fixtures/tail/foobar_single_default.expected b/tests/fixtures/tail/foobar_single_default.expected new file mode 100644 index 000000000..af4f1f055 --- /dev/null +++ b/tests/fixtures/tail/foobar_single_default.expected @@ -0,0 +1,10 @@ +foo +bar +foo +bar +foo +bar +foo +bar +foo +bar diff --git a/tests/fixtures/tail/foobar_stdin_default.expected b/tests/fixtures/tail/foobar_stdin_default.expected new file mode 100644 index 000000000..af4f1f055 --- /dev/null +++ b/tests/fixtures/tail/foobar_stdin_default.expected @@ -0,0 +1,10 @@ +foo +bar +foo +bar +foo +bar +foo +bar +foo +bar diff --git a/tests/tail.rs b/tests/tail.rs new file mode 100644 index 000000000..8b9dc94a3 --- /dev/null +++ b/tests/tail.rs @@ -0,0 +1,23 @@ +#[macro_use] +mod common; + +use common::util::*; + +static UTIL_NAME: &'static str = "tail"; + +static INPUT: &'static str = "foobar.txt"; + + +#[test] +fn test_stdin_default() { + let (at, mut ucmd) = testing(UTIL_NAME); + let result = ucmd.run_piped_stdin(at.read(INPUT)); + assert_eq!(result.stdout, at.read("foobar_stdin_default.expected")); +} + +#[test] +fn test_single_default() { + let (at, mut ucmd) = testing(UTIL_NAME); + let result = ucmd.arg(INPUT).run(); + assert_eq!(result.stdout, at.read("foobar_single_default.expected")); +}