|
@ -87,7 +87,7 @@ void test_addition_addition_basecasezeropluszeroequalzero(void) |
|
|
unsigned int result; |
|
|
unsigned int result; |
|
|
unsigned int expected = 0; |
|
|
unsigned int expected = 0; |
|
|
|
|
|
|
|
|
result = addition(0, 0); |
|
|
|
|
|
|
|
|
result = addition_uint(0, 0); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected, result); |
|
|
TEST_ASSERT_EQUAL_UINT(expected, result); |
|
|
} |
|
|
} |
|
@ -97,8 +97,8 @@ void test_addition_addition_basecaseonescolumns(void) |
|
|
unsigned int result[2]; |
|
|
unsigned int result[2]; |
|
|
unsigned int expected[2] = { 1, 1 }; |
|
|
unsigned int expected[2] = { 1, 1 }; |
|
|
|
|
|
|
|
|
result[0] = addition(1, 0); |
|
|
|
|
|
result[1] = addition(0, 1); |
|
|
|
|
|
|
|
|
result[0] = addition_uint(1, 0); |
|
|
|
|
|
result[1] = addition_uint(0, 1); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -109,11 +109,11 @@ void test_addition_addition_basecasetotenscolumns(void) |
|
|
unsigned int result[5]; |
|
|
unsigned int result[5]; |
|
|
unsigned int expected[5] = { 3, 3, 2, 3, 3 }; |
|
|
unsigned int expected[5] = { 3, 3, 2, 3, 3 }; |
|
|
|
|
|
|
|
|
result[0] = addition(0, 3); |
|
|
|
|
|
result[1] = addition(1, 2); |
|
|
|
|
|
result[2] = addition(1, 1); |
|
|
|
|
|
result[3] = addition(2, 1); |
|
|
|
|
|
result[4] = addition(3, 0); |
|
|
|
|
|
|
|
|
result[0] = addition_uint(0, 3); |
|
|
|
|
|
result[1] = addition_uint(1, 2); |
|
|
|
|
|
result[2] = addition_uint(1, 1); |
|
|
|
|
|
result[3] = addition_uint(2, 1); |
|
|
|
|
|
result[4] = addition_uint(3, 0); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -127,11 +127,11 @@ void test_addition_addition_allunsignedinteger(void) |
|
|
unsigned int result[5]; |
|
|
unsigned int result[5]; |
|
|
unsigned int expected[5] = { 88879736, __UINT32_MAX__, 66558, __UINT32_MAX__, 477905879 }; |
|
|
unsigned int expected[5] = { 88879736, __UINT32_MAX__, 66558, __UINT32_MAX__, 477905879 }; |
|
|
|
|
|
|
|
|
result[0] = addition(13456275, 75423461); |
|
|
|
|
|
result[1] = addition(4294967294, 1); |
|
|
|
|
|
result[2] = addition(1023, 65535); |
|
|
|
|
|
result[3] = addition(0, 4294967295); |
|
|
|
|
|
result[4] = addition(54321567,423584312); |
|
|
|
|
|
|
|
|
result[0] = addition_uint(13456275, 75423461); |
|
|
|
|
|
result[1] = addition_uint(4294967294, 1); |
|
|
|
|
|
result[2] = addition_uint(1023, 65535); |
|
|
|
|
|
result[3] = addition_uint(0, 4294967295); |
|
|
|
|
|
result[4] = addition_uint(54321567,423584312); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -146,8 +146,8 @@ void test_addition_signfloatingnumber(void) |
|
|
unsigned int expected[2] = { 0, 1 }; |
|
|
unsigned int expected[2] = { 0, 1 }; |
|
|
number[0].floating = 1, number[1].floating = -1; |
|
|
number[0].floating = 1, number[1].floating = -1; |
|
|
|
|
|
|
|
|
result[0] = sign(number[0].integer); |
|
|
|
|
|
result[1] = sign(number[1].integer); |
|
|
|
|
|
|
|
|
result[0] = sign_float(number[0].integer); |
|
|
|
|
|
result[1] = sign_float(number[1].integer); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -159,11 +159,11 @@ void test_addition_precisionfloatingnumber(void) |
|
|
number[0].floating = 0, number[1].floating = -34753168, number[2].floating = 75613594, number[3].floating = -0.00000044568721, number[4].floating = 0.0000004796123; |
|
|
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}; |
|
|
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] = precision( number[0].integer ); |
|
|
|
|
|
result[1] = precision( number[1].integer ); |
|
|
|
|
|
result[2] = precision( number[2].integer ); |
|
|
|
|
|
result[3] = precision( number[3].integer ); |
|
|
|
|
|
result[4] = precision( number[4].integer ); |
|
|
|
|
|
|
|
|
result[0] = precision_float( number[0].integer ); |
|
|
|
|
|
result[1] = precision_float( number[1].integer ); |
|
|
|
|
|
result[2] = precision_float( number[2].integer ); |
|
|
|
|
|
result[3] = precision_float( number[3].integer ); |
|
|
|
|
|
result[4] = precision_float( number[4].integer ); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -178,11 +178,11 @@ void test_addition_exponentfloatingnumber(void) |
|
|
number[0].floating = 0, number[1].floating = -762134982, number[2].floating = 47621349, number[3].floating = -0.0000078961354, number[4].floating = 0.00001568943; |
|
|
number[0].floating = 0, number[1].floating = -762134982, number[2].floating = 47621349, number[3].floating = -0.0000078961354, number[4].floating = 0.00001568943; |
|
|
unsigned int expected[5] = { ( number[0].integer << 1) >> 24 , ( number[1].integer << 1) >> 24, ( number[2].integer << 1) >> 24, ( number[3].integer << 1) >> 24, ( number[4].integer << 1) >> 24}; |
|
|
unsigned int expected[5] = { ( number[0].integer << 1) >> 24 , ( number[1].integer << 1) >> 24, ( number[2].integer << 1) >> 24, ( number[3].integer << 1) >> 24, ( number[4].integer << 1) >> 24}; |
|
|
|
|
|
|
|
|
result[0] = exponent( number[0].integer ); |
|
|
|
|
|
result[1] = exponent( number[1].integer ); |
|
|
|
|
|
result[2] = exponent( number[2].integer ); |
|
|
|
|
|
result[3] = exponent( number[3].integer ); |
|
|
|
|
|
result[4] = exponent( number[4].integer ); |
|
|
|
|
|
|
|
|
result[0] = exponent_float( number[0].integer ); |
|
|
|
|
|
result[1] = exponent_float( number[1].integer ); |
|
|
|
|
|
result[2] = exponent_float( number[2].integer ); |
|
|
|
|
|
result[3] = exponent_float( number[3].integer ); |
|
|
|
|
|
result[4] = exponent_float( number[4].integer ); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -195,17 +195,17 @@ void test_addition_addition_precision_positivnumberlowerthan2tothepowerof24(void |
|
|
{ |
|
|
{ |
|
|
unsigned int result[2]; |
|
|
unsigned int result[2]; |
|
|
number[0].floating = 652468761.2348, number[1].floating = 2.675312546943, number[2].floating = 321647956212.2146, number[3].floating = 0.00000324567861, number[4].floating = number[0].floating + number[1].floating; number[5].floating = number[2].floating + number[3].floating; |
|
|
number[0].floating = 652468761.2348, number[1].floating = 2.675312546943, number[2].floating = 321647956212.2146, number[3].floating = 0.00000324567861, number[4].floating = number[0].floating + number[1].floating; number[5].floating = number[2].floating + number[3].floating; |
|
|
unsigned int expected[2] = { precision(number[4].integer), precision(number[5].integer) }; |
|
|
|
|
|
|
|
|
unsigned int expected[2] = { precision_float(number[4].integer), precision_float(number[5].integer) }; |
|
|
|
|
|
|
|
|
unsigned int e0, e1, e2, e3, p0, p1, p2, p3; |
|
|
unsigned int e0, e1, e2, e3, p0, p1, p2, p3; |
|
|
|
|
|
|
|
|
e0 = exponent(number[0].integer), e1 = exponent(number[1].integer), e2 = exponent(number[2].integer), e3 = exponent(number[3].integer); |
|
|
|
|
|
p0 = precision(number[0].integer) | e, p1 = precision(number[1].integer) | e, p2 = precision(number[2].integer) | e, p3 = precision(number[3].integer) | e; |
|
|
|
|
|
|
|
|
e0 = exponent_float(number[0].integer), e1 = exponent_float(number[1].integer), e2 = exponent_float(number[2].integer), e3 = exponent_float(number[3].integer); |
|
|
|
|
|
p0 = precision_float(number[0].integer) | e, p1 = precision_float(number[1].integer) | e, p2 = precision_float(number[2].integer) | e, p3 = precision_float(number[3].integer) | e; |
|
|
|
|
|
|
|
|
p1 >>= e0 - e1, p3 >>= e2 - e3; |
|
|
p1 >>= e0 - e1, p3 >>= e2 - e3; |
|
|
|
|
|
|
|
|
result[0] = addition_precision( p0, p1 ) ^ e; |
|
|
|
|
|
result[1] = addition_precision( p2, p3 ) ^ e; |
|
|
|
|
|
|
|
|
result[0] = addition_precision_float( p0, p1 ) ^ e; |
|
|
|
|
|
result[1] = addition_precision_float( p2, p3 ) ^ e; |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
@ -219,14 +219,14 @@ void test_addition_output_numberwithsignexponentprecision(void) |
|
|
|
|
|
|
|
|
unsigned int s0, s1, s2, s3, s4, e0, e1, e2, e3, e4, p0, p1, p2, p3, p4; |
|
|
unsigned int s0, s1, s2, s3, s4, e0, e1, e2, e3, e4, p0, p1, p2, p3, p4; |
|
|
|
|
|
|
|
|
s0 = sign(number[0].integer), s1 = sign(number[1].integer), s2 = sign(number[2].integer), s3 = sign(number[3].integer), s4 = sign(number[4].integer); |
|
|
|
|
|
e0 = exponent(number[0].integer), e1 = exponent(number[1].integer), e2 = exponent(number[2].integer), e3 = exponent(number[3].integer), e4 = exponent(number[4].integer); |
|
|
|
|
|
p0 = precision(number[0].integer), p1 = precision(number[1].integer), p2 = precision(number[2].integer), p3 = precision(number[3].integer), p4 = precision(number[4].integer); |
|
|
|
|
|
result[0] = output(s0, e0, p0); |
|
|
|
|
|
result[1] = output(s1, e1, p1); |
|
|
|
|
|
result[2] = output(s2, e2, p2); |
|
|
|
|
|
result[3] = output(s3, e3, p3); |
|
|
|
|
|
result[4] = output(s4, e4, p4); |
|
|
|
|
|
|
|
|
s0 = sign_float(number[0].integer), s1 = sign_float(number[1].integer), s2 = sign_float(number[2].integer), s3 = sign_float(number[3].integer), s4 = sign_float(number[4].integer); |
|
|
|
|
|
e0 = exponent_float(number[0].integer), e1 = exponent_float(number[1].integer), e2 = exponent_float(number[2].integer), e3 = exponent_float(number[3].integer), e4 = exponent_float(number[4].integer); |
|
|
|
|
|
p0 = precision_float(number[0].integer), p1 = precision_float(number[1].integer), p2 = precision_float(number[2].integer), p3 = precision_float(number[3].integer), p4 = precision_float(number[4].integer); |
|
|
|
|
|
result[0] = output_float(s0, e0, p0); |
|
|
|
|
|
result[1] = output_float(s1, e1, p1); |
|
|
|
|
|
result[2] = output_float(s2, e2, p2); |
|
|
|
|
|
result[3] = output_float(s3, e3, p3); |
|
|
|
|
|
result[4] = output_float(s4, e4, p4); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|
TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); |
|
|