From a55dfa791f2c07759e9fce0c65288e196ccfd605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Sun, 23 Jun 2024 11:21:26 +0200 Subject: [PATCH] test: add integration --- .../input.txt | 0 .../output.txt | 0 .../{complex-utf8 => complex_utf8}/input.txt | 0 .../{complex-utf8 => complex_utf8}/output.txt | 0 tests/integration_tests.rs | 120 ++++++++++++++++++ 5 files changed, 120 insertions(+) rename tests/fixtures/{10000-unique-keys => 10000_unique_keys}/input.txt (100%) rename tests/fixtures/{10000-unique-keys => 10000_unique_keys}/output.txt (100%) rename tests/fixtures/{complex-utf8 => complex_utf8}/input.txt (100%) rename tests/fixtures/{complex-utf8 => complex_utf8}/output.txt (100%) diff --git a/tests/fixtures/10000-unique-keys/input.txt b/tests/fixtures/10000_unique_keys/input.txt similarity index 100% rename from tests/fixtures/10000-unique-keys/input.txt rename to tests/fixtures/10000_unique_keys/input.txt diff --git a/tests/fixtures/10000-unique-keys/output.txt b/tests/fixtures/10000_unique_keys/output.txt similarity index 100% rename from tests/fixtures/10000-unique-keys/output.txt rename to tests/fixtures/10000_unique_keys/output.txt diff --git a/tests/fixtures/complex-utf8/input.txt b/tests/fixtures/complex_utf8/input.txt similarity index 100% rename from tests/fixtures/complex-utf8/input.txt rename to tests/fixtures/complex_utf8/input.txt diff --git a/tests/fixtures/complex-utf8/output.txt b/tests/fixtures/complex_utf8/output.txt similarity index 100% rename from tests/fixtures/complex-utf8/output.txt rename to tests/fixtures/complex_utf8/output.txt diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index e69de29..eb928c1 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -0,0 +1,120 @@ +use assert_cmd::Command; + +#[test] +fn test_1() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/1/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/1/output.txt")); +} + +#[test] +fn test_2() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/2/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/2/output.txt")); +} + +#[test] +fn test_3() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/3/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/3/output.txt")); +} + +#[test] +fn test_10() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/10/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/10/output.txt")); +} + +#[test] +fn test_20() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/20/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/20/output.txt")); +} + +#[test] +fn test_10000_unique_keys() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/10000_unique_keys/input.txt"]); + command.assert().success().stdout(include_str!( + "../tests/fixtures/10000_unique_keys/output.txt" + )); +} + +#[test] +fn test_boundaries() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/boundaries/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/boundaries/output.txt")); +} + +#[test] +fn test_complex_utf8() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/complex_utf8/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/complex_utf8/output.txt")); +} + +#[test] +fn test_dot() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/dot/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/dot/output.txt")); +} + +#[test] +fn test_rounding() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/rounding/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/rounding/output.txt")); +} + +#[test] +fn test_short() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/short/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/short/output.txt")); +} + +#[test] +fn test_shortest() { + let mut command = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + command.args(["tests/fixtures/shortest/input.txt"]); + command + .assert() + .success() + .stdout(include_str!("../tests/fixtures/shortest/output.txt")); +}