tdd-java-demo
tdd java demo with micro-commits
git clone https://9o.is/git/tdd-java-demo.git
commit 966f06510ac9358e098064db02069e94da0061b2 parent be497a83cdac479b4de05c29ce0fda3d6475d45b Author: Jul <jul@9o.is> Date: Thu, 1 Apr 2021 01:45:48 +0800 include expected totals to test Diffstat:
| M | src/test/java/takehome/RunnerTest.java | | | 9 | +++++++++ |
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/test/java/takehome/RunnerTest.java b/src/test/java/takehome/RunnerTest.java @@ -9,6 +9,7 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.hasItem; class RunnerTest { @@ -24,6 +25,14 @@ class RunnerTest { )); } + @Test + public void totals() { + assertThat(output("3", "2", "0", "0", "0"), hasItem("Total: $3.15")); + assertThat(output("0", "0", "1", "6", "0"), hasItem("Total: $1.90")); + assertThat(output("0", "0", "1", "6", "5"), hasItem("Total: $1.84")); + assertThat(output("2", "1", "0", "3", "5"), hasItem("Total: $1.97")); + } + private List<String> output(String ...inputs) { String input = String.join("\r", inputs); ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());