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.

55 lines
1.1 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "addition.h"
  4. int carry[1];
  5. void setUp(void)
  6. {
  7. }
  8. void tearDown(void)
  9. {
  10. }
  11. void test_addition_full_adder_nullplusnullgleichnull(void)
  12. {
  13. int result[1];
  14. int expected = 0;
  15. full_adder(result, carry, 0, 0, 0);
  16. TEST_ASSERT_EQUAL_INT(expected, result[0]);
  17. }
  18. void test_addition_full_adder_nullplusnullgleichnullmituebertrag(void)
  19. {
  20. int result[1];
  21. int expected = 1;
  22. full_adder(result, carry, 0, 0, 1);
  23. TEST_ASSERT_EQUAL_INT(expected, result[0]);
  24. }
  25. void test_addition_full_adder_zahlpluszahlgleichsummeohneuebertrag(void)
  26. {
  27. int result[5];
  28. int expected[5] = { 0, 1, 1, 1, 1};
  29. full_adder((result+0), carry, 1, 0, 1);
  30. full_adder((result+1), carry, 0, 1, 0);
  31. full_adder((result+2), carry, 1, 0, 0);
  32. full_adder((result+3), carry, 0, 0, 1);
  33. full_adder((result+4), carry, 1, 1, 1);
  34. TEST_ASSERT_EQUAL_INT(expected[0], result[0]);
  35. TEST_ASSERT_EQUAL_INT(expected[1], result[1]);
  36. TEST_ASSERT_EQUAL_INT(expected[2], result[2]);
  37. TEST_ASSERT_EQUAL_INT(expected[3], result[3]);
  38. TEST_ASSERT_EQUAL_INT(expected[4], result[4]);
  39. }
  40. #endif // TEST