From 505b48c0476e99bb880c2d296a91920455a47afa Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Tue, 30 Jan 2024 08:50:33 +0100 Subject: [PATCH] testing: addition full adder complete sum with carry --- test/test_addition.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test_addition.c b/test/test_addition.c index 3678b7f..9596038 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -52,4 +52,27 @@ void test_addition_full_adder_zahlpluszahlgleichsummeohneuebertrag(void) TEST_ASSERT_EQUAL_INT(expected[4], result[4]); } +void test_addition_full_adder_completesumwithcarry(void) +{ + int result[5], carryresult[5]; + int expected[5] = { 0, 0, 1, 1, 0}, expectedcarry[5] = { 1, 1, 1, 0, 0}; + + full_adder(result+0, carryresult+0, 0, 1, 1); + full_adder(result+1, carryresult+1, 1, 1, 0); + full_adder(result+2, carryresult+2, 1, 1, 1); + full_adder(result+3, carryresult+3, 0, 1, 0); + full_adder(result+4, carryresult+4, 0, 0, 0); + + TEST_ASSERT_EQUAL_INT(expected[0], result[0]); + TEST_ASSERT_EQUAL_INT(expected[1], result[1]); + TEST_ASSERT_EQUAL_INT(expected[2], result[2]); + TEST_ASSERT_EQUAL_INT(expected[3], result[3]); + TEST_ASSERT_EQUAL_INT(expected[4], result[4]); + TEST_ASSERT_EQUAL_INT(expectedcarry[0], carryresult[0]); + TEST_ASSERT_EQUAL_INT(expectedcarry[1], carryresult[1]); + TEST_ASSERT_EQUAL_INT(expectedcarry[2], carryresult[2]); + TEST_ASSERT_EQUAL_INT(expectedcarry[3], carryresult[3]); + TEST_ASSERT_EQUAL_INT(expectedcarry[4], carryresult[4]); +} + #endif // TEST