Browse Source

refactoring: rename union in additions test

master
Dennis Sperzel 11 months ago
parent
commit
03758ed163
  1. 38
      test/test_addition.c

38
test/test_addition.c

@ -7,9 +7,9 @@
num carry[1];
union {
float f;
unsigned int i;
} a[5];
float floating;
unsigned int integer;
} number[5];
void setUp(void)
{
@ -138,19 +138,13 @@ void test_addition_addition_allunsignedinteger(void)
TEST_ASSERT_EQUAL_UINT(expected[4], result[4]);
}
void test_addition_signnumber(void) {
void test_addition_signfloatingnumber(void) {
unsigned int result[2];
unsigned int expected[2] = { 0, 1 };
union {
float f;
unsigned int i;
}a;
a.f = 1;
result[0] = s(a.i);
number[0].floating = 1, number[1].floating = -1;
a.f = -1;
result[1] = s(a.i);
result[0] = s(number[0].integer);
result[1] = s(number[1].integer);
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]);
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]);
@ -158,14 +152,14 @@ void test_addition_signnumber(void) {
void test_addition_precisionfloatingnumber(void) {
unsigned int result[5];
a[0].f = 0, a[1].f = -34753168, a[2].f = 75613594, a[3].f = -0.00000044568721, a[4].f = 0.0000004796123;
unsigned int expected[5] = { ( a[0].i << 9) >> 9 , ( a[1].i << 9) >> 9, ( a[2].i << 9) >> 9, ( a[3].i << 9) >> 9, ( a[4].i << 9) >> 9};
number[0].floating = 0, number[1].floating = -34753168, number[2].floating = 75613594, number[3].floating = -0.00000044568721, number[4].floating = 0.0000004796123;
unsigned int expected[5] = { ( number[0].integer << 9) >> 9 , ( number[1].integer << 9) >> 9, ( number[2].integer << 9) >> 9, ( number[3].integer << 9) >> 9, ( number[4].integer << 9) >> 9};
result[0] = m( a[0].i );
result[1] = m( a[1].i );
result[2] = m( a[2].i );
result[3] = m( a[3].i );
result[4] = m( a[4].i );
result[0] = m( number[0].integer );
result[1] = m( number[1].integer );
result[2] = m( number[2].integer );
result[3] = m( number[3].integer );
result[4] = m( number[4].integer );
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]);
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]);
@ -176,9 +170,9 @@ void test_addition_precisionfloatingnumber(void) {
void test_addition_addition_float_0plus0gleich0(void) {
float result;
float expected = 0.0;
float expected = (float) 0.0;
result = addition_float(0.0, 0.0);
result = addition_float( (float) 0.0, (float) 0.0);
TEST_ASSERT_EQUAL_FLOAT(expected, result);
}

Loading…
Cancel
Save