You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
1.9 KiB
93 lines
1.9 KiB
#ifdef TEST
|
|
|
|
#include "unity.h"
|
|
#include "funktionen.h"
|
|
|
|
void setUp(void)
|
|
{
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
void test_square(void) {
|
|
float result = square(2.5);
|
|
/* assert */
|
|
TEST_ASSERT_EQUAL_FLOAT(6.25, result);
|
|
}
|
|
|
|
void test_squareRoot_for_9(void) {
|
|
float result = squareRoot(9.0);
|
|
TEST_ASSERT_EQUAL_FLOAT(3.0, result);
|
|
}
|
|
|
|
void test_cube_for_2(void) {
|
|
float result = cube(2.0);
|
|
TEST_ASSERT_EQUAL_FLOAT(8.0, result);
|
|
}
|
|
|
|
void test_cubeRoot_for_27(void) {
|
|
float result = cubeRoot(27.0);
|
|
TEST_ASSERT_EQUAL_FLOAT(3.0, result);
|
|
}
|
|
|
|
void test_absolute_for_5(void) {
|
|
float result = absolute(-5.0);
|
|
TEST_ASSERT_EQUAL_FLOAT(5.0, result);
|
|
}
|
|
|
|
void test_logarithm_for_100(void) {
|
|
float result = logarithm(100.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 2.0, result);
|
|
}
|
|
|
|
void test_naturalLogarithm_for_100(void) {
|
|
float result = naturalLogarithm(100.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 4.60517, result);
|
|
}
|
|
|
|
|
|
void test_factorial(void) {
|
|
int result = factorial(5);
|
|
TEST_ASSERT_EQUAL_INT(120, result);
|
|
}
|
|
|
|
|
|
void test_floorValue(void) {
|
|
float result = floorValue(5.7);
|
|
TEST_ASSERT_EQUAL_FLOAT(5.0, result);
|
|
}
|
|
|
|
void test_ceilingValue(void) {
|
|
float result = ceilingValue(5.2);
|
|
TEST_ASSERT_EQUAL_FLOAT(6.0, result);
|
|
}
|
|
|
|
void test_absoluteDifference(void) {
|
|
float result = absoluteDifference(8.0, 4.5);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 3.5, result);
|
|
}
|
|
|
|
void test_maximum(void) {
|
|
float result = maximum(5.0, 9.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 9.0, result);
|
|
}
|
|
|
|
void test_minimum(void) {
|
|
float result = minimum(5.0, 9.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 5.0, result);
|
|
}
|
|
|
|
void test_average(void) {
|
|
float result = average(5.0, 9.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 7.0, result);
|
|
}
|
|
|
|
void test_remainderValue(void) {
|
|
float result = remainderValue(10.5, 3.0);
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 1.5, result);
|
|
}
|
|
|
|
|
|
#endif
|