|
@ -11,12 +11,95 @@ void tearDown(void) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_1000_plus_1(void) |
|
|
void test_1000_plus_1(void) |
|
|
{ |
|
|
{ |
|
|
/* arrange */ |
|
|
/* arrange */ |
|
|
int actual; |
|
|
int actual; |
|
|
int expected = 1000; |
|
|
int expected = 1000; |
|
|
|
|
|
|
|
|
|
|
|
void test_square(void) { |
|
|
|
|
|
float result = square(2.5); |
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(6.25, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_squareRoot(void) { |
|
|
|
|
|
float result = squareRoot(9.0); |
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(3.0, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_cube(void) { |
|
|
|
|
|
float result = cube(2.0); |
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(8.0, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_cubeRoot(void) { |
|
|
|
|
|
float result = cubeRoot(27.0); |
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(3.0, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_absolute(void) { |
|
|
|
|
|
float result = absolute(-5.0); |
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(5.0, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_logarithm(void) { |
|
|
|
|
|
float result = logarithm(100.0); |
|
|
|
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 2.0, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_naturalLogarithm(void) { |
|
|
|
|
|
float result = naturalLogarithm(100.0); |
|
|
|
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 4.60517, result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_power(void) { |
|
|
|
|
|
float result = power(2.0, 3.0); |
|
|
|
|
|
TEST_ASSERT_FLOAT_WITHIN(0.000001, 8.0, 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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* act */ |
|
|
/* act */ |
|
|
actual = addThreeNumbers(500, 249, 251); |
|
|
actual = addThreeNumbers(500, 249, 251); |
|
|
|
|
|
|
|
|