@ -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) {
int* result = malloc(sizeof(int));
*result = dividend / divisor;
return result;
@ -0,0 +1,6 @@
#ifndef THEADMIRALS_ARITHMETICDIVISION_H
#define THEADMIRALS_ARITHMETICDIVISION_H
int* division_integer(int, int);
#endif //THEADMIRALS_ARITHMETICDIVISION_H
@ -0,0 +1,10 @@
#include "arithmeticSubtraction.h"
int* subtraction_integer(int a, int b) {
int* result= malloc(sizeof (int));
*result=a - b;
@ -0,0 +1,7 @@
#ifndef THEADMIRALS_ARITHMETICSUBTRACTION_H
#define THEADMIRALS_ARITHMETICSUBTRACTION_H
int* subtraction_integer(int a, int b);
#endif //THEADMIRALS_ARITHMETICSUBTRACTION_H
@ -0,0 +1,18 @@
#include "logarithmicFunctions.h"
#include <math.h>
double* logarithm_two_integer(int base, int num){
if(base <= 1 || num <= 0){
double* result = (double*)malloc(sizeof(double));
if (result == NULL) {
*result = log(num) / log(base);
#ifndef THEADMIRALS_LOGARITHMICFUNCTIONS_H
#define THEADMIRALS_LOGARITHMICFUNCTIONS_H
double* logarithm_two_integer(int base, int num);
#endif //THEADMIRALS_LOGARITHMICFUNCTIONS_H
@ -1,3 +1,4 @@
- Eric Bagus, fdai7812
- Leon Wolf, fdai7845
- Sandro Welte, fdai7728
- Jonas Zitzmann, fdai7791
@ -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);
#include "../src/arithmeticSubtraction.h"
void test_arithmeticSubtraction_subractionoftwonumbers(void) {
int expectedResult = 7;
result = subtraction_integer(14, 7);
#include "../src/logarithmicFunctions.h"
void test_logarithmicFunctions_logarithmiccalculation(void){
double expectedResult = 3.000000;
double* result;
result = logarithm_two_integer(2,8);
TEST_ASSERT_EQUAL_DOUBLE(expectedResult, *result);