mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Add testcase to Ceil Algorithm (#3183)
Co-authored-by: Yang Libin <contact@yanglibin.info>
This commit is contained in:
@ -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)
|
||||
*
|
||||
|
17
src/test/java/com/thealgorithms/maths/CeilTest.java
Normal file
17
src/test/java/com/thealgorithms/maths/CeilTest.java
Normal 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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user