From 74527de98fdc8f2e7cdc4607c255f3c943bf1335 Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Fri, 10 Feb 2023 21:11:51 +0100 Subject: [PATCH] implement unittest for calculatorSquare.c --- build-project.sh | 1 + tests/test_calculatorSquare.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build-project.sh b/build-project.sh index 43a0588..51cf723 100755 --- a/build-project.sh +++ b/build-project.sh @@ -1,4 +1,5 @@ clear +ceedling test:all cd src/ gcc main.c -o main ./main diff --git a/tests/test_calculatorSquare.c b/tests/test_calculatorSquare.c index 3bbf2b1..981dda0 100644 --- a/tests/test_calculatorSquare.c +++ b/tests/test_calculatorSquare.c @@ -2,7 +2,7 @@ #include "unity.h" -#include "calculatorSquare.h" +#include "calculatorSquare.c" void setUp(void) { @@ -12,9 +12,23 @@ void tearDown(void) { } -void test_calculatorSquare_NeedToImplement(void) +void test1_calculatorMultiply(void) { - TEST_IGNORE_MESSAGE("Need to Implement calculatorSquare"); + float p, a, e; + p = 26.24; + a = calculatorSquare(p); + e = p * p; + TEST_ASSERT_EQUAL_FLOAT(e, a); } +void test2_calculatorMultiply(void) +{ + float p, a, e; + p = 5; + a = calculatorSquare(p); + e = p * p; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + + #endif // TEST