From da0dd52871db84df0b44b429affcaa39308a8b07 Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Thu, 9 Feb 2023 00:29:25 +0100 Subject: [PATCH] implement unittest for calculatorMultiply.c --- build-project.sh | 1 + tests/test_calculatorMultiply.c | 99 ++++++++++++++++++++++++++++++++- 2 files changed, 98 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_calculatorMultiply.c b/tests/test_calculatorMultiply.c index 5768561..359fe6b 100644 --- a/tests/test_calculatorMultiply.c +++ b/tests/test_calculatorMultiply.c @@ -12,9 +12,104 @@ void tearDown(void) { } -void test_calculatorMultiply_NeedToImplement(void) +void test1_calculatorMultiply(void) { - TEST_IGNORE_MESSAGE("Need to Implement calculatorMultiply"); + float p, q, a, e; + p = 26.24; + q = 23.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test2_calculatorMultiply(void) +{ + float p, q, a, e; + p = 56.24; + q = 233.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test3_calculatorMultiply(void) +{ + float p, q, a, e; + p = 1226.24; + q = 323.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test4_calculatorMultiply(void) +{ + float p, q, a, e; + p = 2623.24; + q = 2323.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test5_calculatorMultiply(void) +{ + float p, q, a, e; + p = 2435.24; + q = 23423.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test6_calculatorMultiply(void) +{ + float p, q, a, e; + p = 4534.24; + q = 2221.22; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test7_calculatorMultiply(void) +{ + float p, q, a, e; + p = 26322.24; + q = 2332.222; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test8_calculatorMultiply(void) +{ + float p, q, a, e; + p = 26132.24; + q = 2331122.222; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test9_calculatorMultiply(void) +{ + float p, q, a, e; + p = 6322.24; + q = 21232.2322; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); +} + +void test10_calculatorMultiply(void) +{ + float p, q, a, e; + p = 1234.456; + q = 654.4321; + a = calculatorMultiply(p, q); + e = p * q; + TEST_ASSERT_EQUAL_FLOAT(e, a); } #endif // TEST