assert that positive

This commit is contained in:
@hangga 2024-01-20 08:48:38 +07:00
parent 1724f67a39
commit 41370497fd
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package com.baeldung.securerandompositivelong;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.security.SecureRandom;
import static org.assertj.core.api.Assertions.assertThat;
public class SecureRandomPositiveLongUnitTest {
@Test
void whenGenerateRecureRandom_thenGetExpectedValue() {
SecureRandom secureRandom = new SecureRandom();
long randomPositiveLong = Math.abs(secureRandom.nextLong());
assertThat(randomPositiveLong).isPositive();
Double pc = 1.0 / Math.pow(2, 63);
System.out.printf("%.40f", pc);
assertThat(pc).isLessThan(0.00000000000000001);
}
}