From b0acd83da21a082c4ca8fdab32f497dec77deac7 Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Thu, 9 Feb 2023 00:51:50 +0100 Subject: [PATCH] implement unittest for calculatorDivide.c --- build-project.sh | 1 + tests/test_calculatorDivide.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_calculatorDivide.c b/tests/test_calculatorDivide.c index d18118f..1894d0b 100644 --- a/tests/test_calculatorDivide.c +++ b/tests/test_calculatorDivide.c @@ -12,9 +12,105 @@ void tearDown(void) { } -void test_calculatorDivide_NeedToImplement(void) +void test1_calculatorDivide(void) { - TEST_IGNORE_MESSAGE("Need to Implement calculatorDivide"); + float p, q, a, e; + p = 26.24; + q = 23.22; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); } +void test2_calculatorDivide(void) +{ + float p, q, a, e; + p = 2236.24; + q = 2123.22; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test3_calculatorDivide(void) +{ + float p, q, a, e; + p = 623.2; + q = 23.22; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test4_calculatorDivide(void) +{ + float p, q, a, e; + p = 234.7; + q = 124.2; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test5_calculatorDivide(void) +{ + float p, q, a, e; + p = 26207.2; + q = 278.23; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test6_calculatorDivide(void) +{ + float p, q, a, e; + p = 111; + q = 21; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test7_calculatorDivide(void) +{ + float p, q, a, e; + p = 167; + q = 23.22; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test8_calculatorDivide(void) +{ + float p, q, a, e; + p = 26124; + q = 23022; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test9_calculatorDivide(void) +{ + float p, q, a, e; + p = 1234; + q = 4321; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test10_calculatorDivide(void) +{ + float p, q, a, e; + p = 2345; + q = 123.7; + a = calculatorDivide(p, q); + e = p/q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + + #endif // TEST