From 08491f4e7e21ca2e59aaeb90aee0982add800859 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sun, 6 Dec 2020 02:11:04 -0800 Subject: Add regression tests. --- 01/Cargo.toml | 3 ++ 01/tests/main.rs | 17 +++++++ 02/Cargo.toml | 3 ++ 02/tests/main.rs | 15 ++++++ 03/Cargo.toml | 3 ++ 03/tests/main.rs | 21 ++++++++ 04/Cargo.toml | 3 ++ 04/tests/main.rs | 15 ++++++ 05/Cargo.toml | 3 ++ 05/tests/main.rs | 15 ++++++ 06/Cargo.toml | 3 ++ 06/tests/main.rs | 15 ++++++ Cargo.lock | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 260 insertions(+) create mode 100644 01/tests/main.rs create mode 100644 02/tests/main.rs create mode 100644 03/tests/main.rs create mode 100644 04/tests/main.rs create mode 100644 05/tests/main.rs create mode 100644 06/tests/main.rs diff --git a/01/Cargo.toml b/01/Cargo.toml index e9379e7..4534ef6 100644 --- a/01/Cargo.toml +++ b/01/Cargo.toml @@ -6,3 +6,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/01/tests/main.rs b/01/tests/main.rs new file mode 100644 index 0000000..b3d3cec --- /dev/null +++ b/01/tests/main.rs @@ -0,0 +1,17 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_01")?; + + command.arg("input"); + command.assert().success().stdout( + "a: 246, b: 1774, a*b: 436404\n\ + a: 448, b: 721, c: 851, a*b*c: 274879808\n"); + + Ok(()) +} + diff --git a/02/Cargo.toml b/02/Cargo.toml index f4176dc..60a8a3d 100644 --- a/02/Cargo.toml +++ b/02/Cargo.toml @@ -7,3 +7,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } regex = "1" + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/02/tests/main.rs b/02/tests/main.rs new file mode 100644 index 0000000..43289d2 --- /dev/null +++ b/02/tests/main.rs @@ -0,0 +1,15 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_02")?; + + command.arg("input"); + command.assert().success().stdout("628\n705\n"); + + Ok(()) +} + diff --git a/03/Cargo.toml b/03/Cargo.toml index cffd384..189ca3f 100644 --- a/03/Cargo.toml +++ b/03/Cargo.toml @@ -6,3 +6,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/03/tests/main.rs b/03/tests/main.rs new file mode 100644 index 0000000..f68eee5 --- /dev/null +++ b/03/tests/main.rs @@ -0,0 +1,21 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_03")?; + + command.arg("input"); + command.assert().success().stdout( + "dx: 1, dy: 1, trees: 60\n\ + dx: 3, dy: 1, trees: 225\n\ + dx: 5, dy: 1, trees: 57\n\ + dx: 7, dy: 1, trees: 58\n\ + dx: 1, dy: 2, trees: 25\n\ + product: 1115775000\n"); + + Ok(()) +} + diff --git a/04/Cargo.toml b/04/Cargo.toml index 00ee1d2..720a70b 100644 --- a/04/Cargo.toml +++ b/04/Cargo.toml @@ -7,3 +7,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } regex = "1" + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/04/tests/main.rs b/04/tests/main.rs new file mode 100644 index 0000000..e6b8622 --- /dev/null +++ b/04/tests/main.rs @@ -0,0 +1,15 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_04")?; + + command.arg("input"); + command.assert().success().stdout("103\n"); + + Ok(()) +} + diff --git a/05/Cargo.toml b/05/Cargo.toml index 4e5fdbd..aea1a1e 100644 --- a/05/Cargo.toml +++ b/05/Cargo.toml @@ -6,3 +6,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/05/tests/main.rs b/05/tests/main.rs new file mode 100644 index 0000000..b5d0002 --- /dev/null +++ b/05/tests/main.rs @@ -0,0 +1,15 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_05")?; + + command.arg("input"); + command.assert().success().stdout("996\n671\n"); + + Ok(()) +} + diff --git a/06/Cargo.toml b/06/Cargo.toml index e415fff..e5303bd 100644 --- a/06/Cargo.toml +++ b/06/Cargo.toml @@ -6,3 +6,6 @@ edition = "2018" [dependencies] advent_lib = { path = "../lib" } + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/06/tests/main.rs b/06/tests/main.rs new file mode 100644 index 0000000..06bc4fb --- /dev/null +++ b/06/tests/main.rs @@ -0,0 +1,15 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box> { + let mut command = Command::cargo_bin("advent_06")?; + + command.arg("input"); + command.assert().success().stdout("6437\n3229\n"); + + Ok(()) +} + diff --git a/Cargo.lock b/Cargo.lock index 0be294d..a1f009a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,7 @@ name = "advent_01" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", ] [[package]] @@ -12,6 +13,7 @@ name = "advent_02" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", "regex", ] @@ -20,6 +22,7 @@ name = "advent_03" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", ] [[package]] @@ -27,6 +30,7 @@ name = "advent_04" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", "regex", ] @@ -35,6 +39,7 @@ name = "advent_05" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", ] [[package]] @@ -42,6 +47,7 @@ name = "advent_06" version = "0.1.0" dependencies = [ "advent_lib", + "assert_cmd", ] [[package]] @@ -57,6 +63,40 @@ dependencies = [ "memchr", ] +[[package]] +name = "assert_cmd" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7ac5c260f75e4e4ba87b7342be6edcecbcb3eb6741a0507fda7ad115845cc65" +dependencies = [ + "escargot", + "predicates", + "predicates-core", + "predicates-tree", +] + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "escargot" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19db1f7e74438642a5018cdf263bb1325b2e792f02dd0a3ca6d6c0f0d7b1d5a5" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + [[package]] name = "lazy_static" version = "1.4.0" @@ -69,6 +109,50 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "predicates" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" +dependencies = [ + "difference", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" + +[[package]] +name = "predicates-tree" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +dependencies = [ + "predicates-core", + "treeline", +] + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + [[package]] name = "regex" version = "1.4.2" @@ -87,6 +171,54 @@ version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "serde" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -95,3 +227,15 @@ checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ "lazy_static", ] + +[[package]] +name = "treeline" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -- cgit 1.4.1