From 826b612d0d314f87e202d00de2c417394d8e2200 Mon Sep 17 00:00:00 2001 From: Ankush Banik <86042508+Ankush263@users.noreply.github.com> Date: Thu, 7 Jul 2022 11:54:24 +0530 Subject: [PATCH] Add testcase to Ceil Algorithm (#3183) Co-authored-by: Yang Libin --- src/main/java/com/thealgorithms/maths/Ceil.java | 8 -------- .../java/com/thealgorithms/maths/CeilTest.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/test/java/com/thealgorithms/maths/CeilTest.java diff --git a/src/main/java/com/thealgorithms/maths/Ceil.java b/src/main/java/com/thealgorithms/maths/Ceil.java index 2263f9e6..08cc05cf 100644 --- a/src/main/java/com/thealgorithms/maths/Ceil.java +++ b/src/main/java/com/thealgorithms/maths/Ceil.java @@ -4,14 +4,6 @@ import java.util.Random; public class Ceil { - public static void main(String[] args) { - Random random = new Random(); - for (int i = 1; i <= 1000; ++i) { - double randomNumber = random.nextDouble(); - assert ceil(randomNumber) == Math.ceil(randomNumber); - } - } - /** * Returns the smallest (closest to negative infinity) * diff --git a/src/test/java/com/thealgorithms/maths/CeilTest.java b/src/test/java/com/thealgorithms/maths/CeilTest.java new file mode 100644 index 00000000..e57e23f1 --- /dev/null +++ b/src/test/java/com/thealgorithms/maths/CeilTest.java @@ -0,0 +1,17 @@ +package com.thealgorithms.maths; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class CeilTest { + + @Test + void testCeil() { + assertEquals(8, Ceil.ceil(7.057)); + assertEquals(8, Ceil.ceil(7.004)); + assertEquals(-13, Ceil.ceil(-13.004)); + assertEquals(1, Ceil.ceil(.98)); + assertEquals(-11, Ceil.ceil(-11.357)); + } +}