|
|
@ -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)); |
|
|
|
} |
|
|
|