Browse Source
Unittest and refractoring Moved ConX functions to Taschenrechner.h and main_Taschenrechner.c and added Unittests
remotes/origin/feature
Unittest and refractoring Moved ConX functions to Taschenrechner.h and main_Taschenrechner.c and added Unittests
remotes/origin/feature
Enrico Schellenberger
11 months ago
4 changed files with 438 additions and 395 deletions
-
353src/main/c/ConvertMode.c
-
353src/main/c/main_taschenrechner.c
-
13src/main/c/taschenrechner.h
-
114src/test/c/test_taschenrechner.c
@ -1,42 +1,72 @@ |
|||
#ifdef TEST |
|||
|
|||
#include "unity.h" |
|||
|
|||
#include "taschenrechner.h" |
|||
|
|||
void setUp(void) |
|||
{ |
|||
} |
|||
|
|||
void tearDown(void) |
|||
{ |
|||
} |
|||
|
|||
void test_addition(void) |
|||
{ |
|||
doulbe result = add(1, 2); |
|||
TEST_ASSERT_EQUAL(3, result); |
|||
} |
|||
|
|||
void test_minus(void) |
|||
{ |
|||
doulbe result = minus(3, 1); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
} |
|||
|
|||
void test_multiply(void) |
|||
{ |
|||
doulbe result = multiply(1, 2); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
} |
|||
|
|||
void test_divide(void) |
|||
{ |
|||
doulbe result = divide(4, 2); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
|
|||
doulbe result1 = divide(4, 0); |
|||
TEST_ASSERT_EQUAL(0, result1); |
|||
} |
|||
|
|||
#endif // TEST |
|||
#ifdef TEST |
|||
|
|||
#include "unity.h" |
|||
|
|||
#include "taschenrechner.h" |
|||
|
|||
void setUp(void) |
|||
{ |
|||
} |
|||
|
|||
void tearDown(void) |
|||
{ |
|||
} |
|||
|
|||
void test_addition(void) |
|||
{ |
|||
doulbe result = add(1, 2); |
|||
TEST_ASSERT_EQUAL(3, result); |
|||
} |
|||
|
|||
void test_minus(void) |
|||
{ |
|||
doulbe result = minus(3, 1); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
} |
|||
|
|||
void test_multiply(void) |
|||
{ |
|||
doulbe result = multiply(1, 2); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
} |
|||
|
|||
void test_divide(void) |
|||
{ |
|||
doulbe result = divide(4, 2); |
|||
TEST_ASSERT_EQUAL(2, result); |
|||
|
|||
doulbe result1 = divide(4, 0); |
|||
TEST_ASSERT_EQUAL(0, result1); |
|||
} |
|||
|
|||
void test_ConMeter(void) {//5 mm to cm |
|||
double result = ConMeter(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(50, result); |
|||
} |
|||
|
|||
void test_ConMeterToFoot(void) {//5 m to foot |
|||
double result = ConMeterToFoot(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(16.4042, result); |
|||
} |
|||
void test_ConKilometerToMiles(void) {//5 miles to km |
|||
double result = ConKilometerToMiles(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(3.10686, result); |
|||
} |
|||
|
|||
void test_ConGram(void) {//5 mg to g |
|||
double result = ConGram(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(5000, result); |
|||
} |
|||
|
|||
void test_ConGramToPounds(void) {//5 kg to pounds |
|||
double result = ConGramToPounds(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(11.0231, result); |
|||
} |
|||
|
|||
void test_ConTemp(void) {//5 celsius to fahrenheit |
|||
double result = ConTemp(5, 0, 1); |
|||
TEST_ASSERT_EQUAL(41, result); |
|||
} |
|||
|
|||
|
|||
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue