Browse Source

added arithmetic Multiplication

remotes/origin/develop
Sandro Welte 11 months ago
parent
commit
83b4f6496e
  1. 17
      src/arithmeticMultiplication_Int.c
  2. 8
      src/arithmeticMultiplication_Int.h
  3. 21
      test/test_arithmeticMultiplication_Int.c

17
src/arithmeticMultiplication_Int.c

@ -0,0 +1,17 @@
#include "arithmeticMultiplication_Int.h"
#include <stdlib.h>
int* multiplication_integer(int num1, int num2) {
int *result = (int*)malloc(sizeof(int));
if (result == NULL) {
// Handle memory allocation failure
return NULL;
}
*result = num1 * num2;
return result;
}

8
src/arithmeticMultiplication_Int.h

@ -0,0 +1,8 @@
#ifndef THEADMIRALS_ARITHMETICMULTIPLICATION_INT_H
#define THEADMIRALS_ARITHMETICMULTIPLICATION_INT_H
int* multiplication_integer(int, int);
#endif //THEADMIRALS_ARITHMETICMULTIPLICATION_INT_H

21
test/test_arithmeticMultiplication_Int.c

@ -0,0 +1,21 @@
#include "../src/arithmeticMultiplication_Int.h"
#include "unity.h"
#include "limits.h"
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
void test_arithmeticMultiplication_numbertimesnumberequalsnumber(void) {
int expectedResult = 10;
int* result;
result = multiplication_integer(2,5);
TEST_ASSERT_EQUAL_INT(expectedResult, *result);
}
Loading…
Cancel
Save