@ -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,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);