mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 06:55:02 +08:00
Code refactor for AbsoluteValue improvements (#3018)
Fix #3017 Co-authored-by: Yang Libin <szuyanglb@outlook.com>
This commit is contained in:
18
src/test/java/com/thealgorithms/maths/AbsoluteValueTest.java
Normal file
18
src/test/java/com/thealgorithms/maths/AbsoluteValueTest.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.thealgorithms.maths;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class AbsoluteValueTest {
|
||||
|
||||
@Test
|
||||
void testGetAbsValue() {
|
||||
Stream.generate(() -> ThreadLocalRandom.current().nextInt())
|
||||
.limit(1000)
|
||||
.forEach(number -> assertEquals(Math.abs(number), AbsoluteValue.getAbsValue(number)));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user