From c3d8d6f8e54dc1de4d1e595d1a4045fa12098dda Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 4 Jan 2025 10:45:34 -0500 Subject: [PATCH] Validation tests. --- test/validation/test.bats | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/validation/test.bats diff --git a/test/validation/test.bats b/test/validation/test.bats new file mode 100644 index 0000000..686065e --- /dev/null +++ b/test/validation/test.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats + +bin() { ./scl.out $1 | tail -n1; } + +@test "simple addition" { + run bin "1+1" + [ "$output" = "= 2.000000" ] + + run bin "-1+1" + [ "$output" = "= 0.000000" ] + + run bin "1+-1" + [ "$output" = "= 0.000000" ] + + run bin "-1+-1" + [ "$output" = "= -2.000000" ] +} + +@test "simple subtraction" { + run bin "1-1" + [ "$output" = "= 0.000000" ] + + run bin "-1-1" + [ "$output" = "= -2.000000" ] + + run bin "1--1" + [ "$output" = "= 2.000000" ] + + run bin "-1--1" + [ "$output" = "= 0.000000" ] +} + +@test "simple multiplication" { + run bin "1*2" + [ "$output" = "= 2.000000" ] + + run bin "-1*2" + [ "$output" = "= -2.000000" ] + + run bin "1*-1" + [ "$output" = "= -1.000000" ] + + run bin "-1*-1" + [ "$output" = "= 1.000000" ] +} + +@test "simple division" { + run bin "1/2" + [ "$output" = "= 0.500000" ] + + run bin "-1/2" + [ "$output" = "= -0.500000" ] + + run bin "1/-1" + [ "$output" = "= -1.000000" ] + + run bin "-1/-1" + [ "$output" = "= 1.000000" ] +}