diff --git a/src/exponentials.c b/src/exponentials.c new file mode 100644 index 0000000..389997b --- /dev/null +++ b/src/exponentials.c @@ -0,0 +1,9 @@ +#include "exponentials.h" +#include +#include + +double* exponentials_double(int base, int exponent) { + double* result = malloc(sizeof(double)); + *result = pow(base, exponent); + return result; +} \ No newline at end of file diff --git a/src/exponentials.h b/src/exponentials.h new file mode 100644 index 0000000..49ab5b9 --- /dev/null +++ b/src/exponentials.h @@ -0,0 +1,6 @@ +#ifndef THEADMIRALS_EXPONENTIALS_H +#define THEADMIRALS_EXPONENTIALS_H + +double* exponentials_double(int, int); + +#endif //THEADMIRALS_EXPONENTIALS_H diff --git a/test/test_exponentials.c b/test/test_exponentials.c new file mode 100644 index 0000000..6266ac7 --- /dev/null +++ b/test/test_exponentials.c @@ -0,0 +1,18 @@ +#include "../src/exponentials.h" +#include "unity.h" +#include "limits.h" + +void setUp(void) { + // set stuff up here +} + +void tearDown(void) { + // clean stuff up here +} + +void test_exponentials_calculatenumfrombaseandexponent(void) { + double expectedResult = 32.000000; + double* result; + result = exponentials_double(2, 5); + TEST_ASSERT_EQUAL_DOUBLE(expectedResult, *result); +} \ No newline at end of file