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.

129 lines
2.6 KiB

#ifdef TEST
#include "unity.h"
#include "minirechner.h"
void setUp(void)
{
}
void tearDown(void)
{
}
// test addition
void test_minitaschenrechner_3_plus_4(void)
{
float result = addieren(3, 4);
TEST_ASSERT_EQUAL(7, result);
}
void test_minitaschenrechner_float_plus_float(void)
{
float result = addieren(3.1, 4.2);
TEST_ASSERT_EQUAL(7.3, result);
}
void test_minitaschenrechner_minus1_plus_minus3(void)
{
float result = addieren(-1, -3);
TEST_ASSERT_EQUAL(-4, result);
}
void test_minitaschenrechner_0_plus_2(void)
{
float result = addieren(0, 2);
TEST_ASSERT_EQUAL(2, result);
}
// test subtraktion
void test_minitaschenrechner_5_minus_2(void)
{
float result = subtrahieren(5, 2);
TEST_ASSERT_EQUAL(3, result);
}
void test_minitaschenrechner_float_minus_float(void)
{
float result = subtrahieren(2.7, 1.3);
TEST_ASSERT_EQUAL(1.4, result);
}
void test_minitaschenrechner_minus7_minus_minus3(void)
{
float result = subtrahieren(-7, -3);
TEST_ASSERT_EQUAL(-4, result);
}
void test_minitaschenrechner_4_minus_0(void)
{
float result = subtrahieren(4, 0);
TEST_ASSERT_EQUAL(4, result);
}
// test multiplikation
void test_minitaschenrechner_8_mal_3(void)
{
float result = multiplizieren(8, 3);
TEST_ASSERT_EQUAL(24, result);
}
void test_minitaschenrechner_minus3_mal_minus4(void)
{
float result = multiplizieren(-3, -4);
TEST_ASSERT_EQUAL(12, result);
}
void test_minitaschenrechner_0_mal_5(void)
{
float result = multiplizieren(0, 5);
TEST_ASSERT_EQUAL(0, result);
}
// test dividieren
void test_minitaschenrechner_9_durch_3(void)
{
float result = dividieren(9, 3);
TEST_ASSERT_EQUAL(3, result);
}
void test_minitaschenrechner_minus6_durch_minus2(void)
{
float result = dividieren(-6, -2);
TEST_ASSERT_EQUAL(3, result);
}
void test_minitaschenrechner_0_durch_5(void)
{
float result = dividieren(0, 5);
TEST_ASSERT_EQUAL(0, result);
}
// test rest
void test_minitaschenrechner_14_rest_5(void)
{
float result = rest(14, 5);
TEST_ASSERT_EQUAL(4, result);
}
void test_minitaschenrechner_1_rest_7(void)
{
float result = rest(0, 7);
TEST_ASSERT_EQUAL(0, result);
}
// test groesster gemeinsammer Teiler
void test_minitaschenrechner_120_groesster_gemeinsammer_teiler_30(void)
{
float result = groesster_gemeinsammer_teiler(120, 30);
TEST_ASSERT_EQUAL(30, result);
}
// test kleinstes gemeinsammes Vielfaches
void test_minitaschenrechner_120_kleinstes_gemeinsammes_vielfaches_50(void)
{
float result = kleinstes_gemeinsammes_vielfaches(120, 50);
TEST_ASSERT_EQUAL(600, result);
}
#endif // TEST