From 11d826f89604fd447ab7be9069b2f919d1c814a0 Mon Sep 17 00:00:00 2001 From: Liana Date: Fri, 19 Dec 2025 15:41:41 +0000 Subject: [PATCH] Add bash app, tests and run_tests file --- README.md | 0 app/calculator.sh | 6 ++++++ run_tests.sh | 29 +++++++++++++++++++++++++++++ tests/test_calculator.sh | 19 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 README.md create mode 100755 app/calculator.sh create mode 100755 run_tests.sh create mode 100755 tests/test_calculator.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/app/calculator.sh b/app/calculator.sh new file mode 100755 index 0000000..53685c5 --- /dev/null +++ b/app/calculator.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +add() { +echo $(($1+$2)) +} + diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..60f2c60 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +echo "Pornesc rularea testelor..." + +FAILED=0 + +for test in tests/*.sh; do +echo "Rulez $test" +bash "$test" + +if [ $? -ne 0 ]; then +FAILED=1 + +fi + +done + + +if [ $FAILED -eq 0 ]; then +echo "Toate testele au trecut" +exit 0 + +else +echo "Unele teste au esuat" +exit 1 + +fi + + diff --git a/tests/test_calculator.sh b/tests/test_calculator.sh new file mode 100755 index 0000000..3746089 --- /dev/null +++ b/tests/test_calculator.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#incarca functia din aplicatie + +source ./app/calculator.sh + +echo "Test: add 2 + 3" + +result=$( add 2 3 ) + +if [ "$result" -eq 5 ]; then +echo "Test PASSED" +exit 0 + +else +echo "Test FAILED" +exit 1 +fi +