Browse Source

refactoring: function full_adder and variables

master
Dennis Sperzel 11 months ago
parent
commit
1ed9c0bf69
  1. 4
      src/addition.c
  2. 2
      src/addition.h
  3. 8
      test/test_addition.c

4
src/addition.c

@ -1,6 +1,6 @@
#include "addition.h" #include "addition.h"
#include <stdlib.h> #include <stdlib.h>
void volladdierer (int* s, int* nc, int a, int b, int c) {
s[0] = c;
void full_adder (int* sum, int* nextcarry, int number1, int number2, int carry) {
sum[0] = carry;
} }

2
src/addition.h

@ -1,6 +1,6 @@
#ifndef ADDITION_H #ifndef ADDITION_H
#define ADDITION_H #define ADDITION_H
void volladdierer (int* s, int* nc, int a, int b, int c);
void full_adder (int* sum, int* nextcarry, int number1, int number2, int carry);
#endif // ADDITION_H #endif // ADDITION_H

8
test/test_addition.c

@ -14,22 +14,22 @@ void tearDown(void)
{ {
} }
void test_addition_volladdierer_nullplusnullgleichnull(void)
void test_addition_full_adder_nullplusnullgleichnull(void)
{ {
int result[1]; int result[1];
int expected = 0; int expected = 0;
volladdierer(result, nullcarry, 0, 0, 0);
full_adder(result, nullcarry, 0, 0, 0);
TEST_ASSERT_EQUAL_INT(expected, result[0]); TEST_ASSERT_EQUAL_INT(expected, result[0]);
} }
void test_addition_volladdierer_nullplusnullgleichnullmituebertrag(void)
void test_addition_full_adder_nullplusnullgleichnullmituebertrag(void)
{ {
int result[1]; int result[1];
int expected = 1; int expected = 1;
volladdierer(result, nullcarry, 0, 0, 1);
full_adder(result, nullcarry, 0, 0, 1);
TEST_ASSERT_EQUAL_INT(expected, result[0]); TEST_ASSERT_EQUAL_INT(expected, result[0]);
} }

Loading…
Cancel
Save