From 84da853102797d455218755ccd96acf42b114ea9 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Thu, 2 Feb 2023 09:16:56 +0100 Subject: [PATCH] Implementation of unit tests for power() and add line to build-script in order to call ceedling from there. --- build-script.sh | 1 + test/test_StringManipulation.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/build-script.sh b/build-script.sh index 61629a5..13a9de2 100755 --- a/build-script.sh +++ b/build-script.sh @@ -1,4 +1,5 @@ clear +ceedling test:all cd src/ gcc stringManipulation.c loginCustomer.c createCustomer.c mainMenu.c program.c -lm -o program.out ./program.out diff --git a/test/test_StringManipulation.c b/test/test_StringManipulation.c index cd681bf..af7c1fb 100644 --- a/test/test_StringManipulation.c +++ b/test/test_StringManipulation.c @@ -1,8 +1,23 @@ +#include #include #include #include #include "../src/stringManipulation.c" + +void test_power() +{ + /*initializing test values*/ + int testValues[] = {1,2,3,4,5,6,7,8,9}; + int expectedValues[] = {1,4,9,16,25,36,49,64,81}; + int length = sizeof(testValues)/sizeof(int); + /*assertions*/ + const int exponent = 2; + for(int i=0;i