diff --git a/src/test/math/math.c b/src/test/math/math.c index 4a8319f..42f245d 100644 --- a/src/test/math/math.c +++ b/src/test/math/math.c @@ -19,6 +19,10 @@ long cModulo(long x, long y) { return x % y; } +long cDiv(long x, long y) +{ + return x / y; +} long cNeg(long x) { return -x; @@ -173,6 +177,15 @@ int runMathTests() math_test("mul", cMul, mul, 1, 5); math_test("mul", cMul, mul, -1, -1); + printf("\nDivision Tests\n"); + math_test("div", cDiv, div, 10, 2); + math_test("div", cDiv, div, 8, 4); + math_test("div", cDiv, div, 6, -2); + math_test("div", cDiv, div, -9, 3); + math_test("div", cDiv, div, 9, 2); + math_test("div", cDiv, div, 9, -2); + math_test("div", cDiv, div, -9, 2); + printf("\nModulo Tests \n"); math_test("modulo", cModulo, modulo, 1, 1); math_test("modulo", cModulo, modulo, 1, 5); diff --git a/src/test/math/math.h b/src/test/math/math.h index d42636d..0af7ad9 100644 --- a/src/test/math/math.h +++ b/src/test/math/math.h @@ -5,6 +5,7 @@ long add(long x, long y); long sub(long x, long y); long mul(long x, long y); +long div(long x, long y); long modulo(long x, long y); long neg(long x); long id(long x); diff --git a/src/test/test.k b/src/test/test.k index 5a9104b..539f333 100644 --- a/src/test/test.k +++ b/src/test/test.k @@ -10,6 +10,10 @@ function mul(x: int, y: int): int { return (x * y); } +function div(x: int, y: int): int { + return (x / y); +} + function modulo(x: int, y: int): int { return (x % y); }