Browse Source

Implementation of unit tests for power() and add line to build-script in order to call ceedling from there.

remotes/origin/development
fdai7057 2 years ago
parent
commit
84da853102
  1. 1
      build-script.sh
  2. 16
      test/test_StringManipulation.c

1
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

16
test/test_StringManipulation.c

@ -1,8 +1,23 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unity.h>
#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<length;++i){
TEST_ASSERT_EQUAL_INT(expectedValues[i], power(testValues[i],exponent));
}
}
void test_to_string()
{
/*initializing test values*/
@ -13,6 +28,7 @@ void test_to_string()
char *result_5[] = {"1000000","2000000","3000000","4000000","5000000","6000000","7000000",
"8000000","9000000","10000000"};
/*assertions*/
for(int i=0;i<=10;++i){
TEST_ASSERT_EQUAL_STRING(result_1[i],to_string(i));
}

Loading…
Cancel
Save