From ee8a08bfa24d9a3d09273fdebe8d73ac38c545f9 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:30:39 +0200 Subject: Update guessing game Signed-off-by: Carlos Maiolino --- rust/echor/tests/.cli.rs.un~ | Bin 0 -> 10463 bytes rust/echor/tests/cli.rs | 27 +++++++++++++++++++++++++++ rust/echor/tests/cli.rs~ | 26 ++++++++++++++++++++++++++ rust/echor/tests/expected/hello1.txt | 1 + 4 files changed, 54 insertions(+) create mode 100644 rust/echor/tests/.cli.rs.un~ create mode 100644 rust/echor/tests/cli.rs create mode 100644 rust/echor/tests/cli.rs~ create mode 100644 rust/echor/tests/expected/hello1.txt (limited to 'rust/echor/tests') diff --git a/rust/echor/tests/.cli.rs.un~ b/rust/echor/tests/.cli.rs.un~ new file mode 100644 index 0000000..7a6e081 Binary files /dev/null and b/rust/echor/tests/.cli.rs.un~ differ diff --git a/rust/echor/tests/cli.rs b/rust/echor/tests/cli.rs new file mode 100644 index 0000000..e78eb36 --- /dev/null +++ b/rust/echor/tests/cli.rs @@ -0,0 +1,27 @@ +use assert_cmd::Command; +use predicates::prelude::*; +use std::fs; + +#[test] +fn dies_no_args() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.assert() + .failure() + .stderr(predicate::str::contains("USAGE")); +} + +#[test] +fn runs() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Howdy partner").assert().success(); +} + +#[test] +fn hello1() { + let expected = fs::read_to_string("tests/expected/hello1.txt").unwrap(); + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Hello there") + .assert() + .success() + .stdout(expected); +} diff --git a/rust/echor/tests/cli.rs~ b/rust/echor/tests/cli.rs~ new file mode 100644 index 0000000..d6e32b1 --- /dev/null +++ b/rust/echor/tests/cli.rs~ @@ -0,0 +1,26 @@ +use assert_cmd::Command; +use predicates::prelude::*; + +#[test] +fn dies_no_args() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.assert() + .failure() + .stderr(predicate::str::contains("USAGE")); +} + +#[test] +fn runs() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Howdy partner").assert().success(); +} + +#[test] +fn hello1() { + let expected = fs::read_to_string("tests/expected/hello1.txt").unwrap(); + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Hello there") + .assert() + .success() + .stdout(expected); +} diff --git a/rust/echor/tests/expected/hello1.txt b/rust/echor/tests/expected/hello1.txt new file mode 100644 index 0000000..d6613f5 --- /dev/null +++ b/rust/echor/tests/expected/hello1.txt @@ -0,0 +1 @@ +Hello there -- cgit v1.2.3