Add testcase to Ceil Algorithm (#3183)

Co-authored-by: Yang Libin <contact@yanglibin.info>
This commit is contained in:
Ankush Banik 2022-07-07 11:54:24 +05:30 committed by GitHub
parent 8c8a61a224
commit 826b612d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -4,14 +4,6 @@ import java.util.Random;
public class Ceil { 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) * Returns the smallest (closest to negative infinity)
* *

View File

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