Browse Source

Merge branch 'develop' of https://gitlab.cs.hs-fulda.de/fdai7812/theadmirals into develop

remotes/origin/develop
Sandro Welte 11 months ago
parent
commit
bb100c2e82
  1. 17
      src/arithmeticDivision.c
  2. 6
      src/arithmeticDivision.h
  3. 10
      src/arithmeticSubtraction.c
  4. 7
      src/arithmeticSubtraction.h
  5. 18
      src/logarithmicFunctions.c
  6. 6
      src/logarithmicFunctions.h
  7. 3
      team.md
  8. 19
      test/test_arithmeticDivision.c
  9. 18
      test/test_arithmeticSubtraction.c
  10. 18
      test/test_logarithmicFunctions.c

17
src/arithmeticDivision.c

@ -0,0 +1,17 @@
#include "arithmeticDivision.h"
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int* division_integer(int dividend, int divisor) {
if(divisor == 0) {
return NULL;
}
// Overflow protection
if (dividend == INT_MIN && divisor == -1) {
return NULL;
}
int* result = malloc(sizeof(int));
*result = dividend / divisor;
return result;
}

6
src/arithmeticDivision.h

@ -0,0 +1,6 @@
#ifndef THEADMIRALS_ARITHMETICDIVISION_H
#define THEADMIRALS_ARITHMETICDIVISION_H
int* division_integer(int, int);
#endif //THEADMIRALS_ARITHMETICDIVISION_H

10
src/arithmeticSubtraction.c

@ -0,0 +1,10 @@
#include "arithmeticSubtraction.h"
#include <stdlib.h>
int* subtraction_integer(int a, int b) {
int* result= malloc(sizeof (int));
*result=a - b;
return result;
}

7
src/arithmeticSubtraction.h

@ -0,0 +1,7 @@
#ifndef THEADMIRALS_ARITHMETICSUBTRACTION_H
#define THEADMIRALS_ARITHMETICSUBTRACTION_H
int* subtraction_integer(int a, int b);
#endif //THEADMIRALS_ARITHMETICSUBTRACTION_H

18
src/logarithmicFunctions.c

@ -0,0 +1,18 @@
#include "logarithmicFunctions.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double* logarithm_two_integer(int base, int num){
if(base <= 1 || num <= 0){
return NULL;
}
double* result = (double*)malloc(sizeof(double));
if (result == NULL) {
return NULL;
}
*result = log(num) / log(base);
return result;
}

6
src/logarithmicFunctions.h

@ -0,0 +1,6 @@
#ifndef THEADMIRALS_LOGARITHMICFUNCTIONS_H
#define THEADMIRALS_LOGARITHMICFUNCTIONS_H
double* logarithm_two_integer(int base, int num);
#endif //THEADMIRALS_LOGARITHMICFUNCTIONS_H

3
team.md

@ -1,3 +1,4 @@
- Eric Bagus, fdai7812
- Leon Wolf, fdai7845
- Sandro Welte, fdai7728
- Sandro Welte, fdai7728
- Jonas Zitzmann, fdai7791

19
test/test_arithmeticDivision.c

@ -0,0 +1,19 @@
#include "../src/arithmeticDivision.h"
#include "unity.h"
#include "limits.h"
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
void test_arithmeticDivision_numberdividedbynumberequalsnumber(void) {
int expectedResult = 2;
int* result;
result = division_integer(14, 7);
TEST_ASSERT_EQUAL_INT(expectedResult, *result);
}

18
test/test_arithmeticSubtraction.c

@ -0,0 +1,18 @@
#include "../src/arithmeticSubtraction.h"
#include "unity.h"
#include "limits.h"
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
void test_arithmeticSubtraction_subractionoftwonumbers(void) {
int expectedResult = 7;
int* result;
result = subtraction_integer(14, 7);
TEST_ASSERT_EQUAL_INT(expectedResult, *result);
}

18
test/test_logarithmicFunctions.c

@ -0,0 +1,18 @@
#include "../src/logarithmicFunctions.h"
#include "unity.h"
#include "limits.h"
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
void test_logarithmicFunctions_logarithmiccalculation(void){
double expectedResult = 3.000000;
double* result;
result = logarithm_two_integer(2,8);
TEST_ASSERT_EQUAL_DOUBLE(expectedResult, *result);
}
Loading…
Cancel
Save