From c19f56958b4b737cd0164a425ce1d39299c45b30 Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Thu, 9 Feb 2023 00:16:29 +0100 Subject: [PATCH] implement unittest for calculatorSubtract.c --- build-project.sh | 1 + tests/test_calculatorSubtract.c | 100 +++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 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_calculatorSubtract.c b/tests/test_calculatorSubtract.c index 498d037..abf9859 100644 --- a/tests/test_calculatorSubtract.c +++ b/tests/test_calculatorSubtract.c @@ -12,9 +12,105 @@ void tearDown(void) { } -void test_calculatorSubtract_NeedToImplement(void) + +void test1_calculatorSubtract(void) +{ + float p, q, a, e; + p = 123.211; + q = 112.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test2_calculatorSubtract(void) +{ + float p, q, a, e; + p = 13.21; + q = 112.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test3_calculatorSubtract(void) +{ + float p, q, a, e; + p = 12231.211; + q = 1122.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test4_calculatorSubtract(void) +{ + float p, q, a, e; + p = 113453.211; + q = 11254.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test5_calculatorSubtract(void) +{ + float p, q, a, e; + p = 12133.211; + q = 112.231; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test6_calculatorSubtract(void) +{ + float p, q, a, e; + p = 1133.201; + q = 11221.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test7_calculatorSubtract(void) +{ + float p, q, a, e; + p = 12213.2211; + q = 111.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test8_calculatorSubtract(void) +{ + float p, q, a, e; + p = 16213.711; + q = 1214.2251; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test9_calculatorSubtract(void) +{ + float p, q, a, e; + p = 1933.611; + q = 1432.21; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test10_calculatorSubtract(void) { - TEST_IGNORE_MESSAGE("Need to Implement calculatorSubtract"); + float p, q, a, e; + p = 1233.811; + q = 1121.131; + e = p - q; + a = calculatorSubtract(p, q); + TEST_ASSERT_EQUAL_FLOAT(e, a); } #endif // TEST