From 5df550eb95b1c19ca122cc03250b46d89b083de6 Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Date: Mon, 15 Mar 2021 23:49:15 +0100 Subject: [PATCH] Enable Float test Extract number of threads to constant --- .../luiz/base/numbers/CustomizedNumberTest.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/base/src/test/java/com/costa/luiz/base/numbers/CustomizedNumberTest.java b/base/src/test/java/com/costa/luiz/base/numbers/CustomizedNumberTest.java index 534c52d..b0f2eba 100644 --- a/base/src/test/java/com/costa/luiz/base/numbers/CustomizedNumberTest.java +++ b/base/src/test/java/com/costa/luiz/base/numbers/CustomizedNumberTest.java @@ -21,9 +21,12 @@ import java.util.stream.LongStream; import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; class CustomizedNumberTest implements WithAssertions { + public static final int THREADS = 5; + @BeforeEach void setUp() { } @@ -66,13 +69,11 @@ void playingWithDouble() { assertThat(myDouble.floatValue()).isEqualTo(myFloat); } - @Disabled @Test void playingWithFloat() { Float myFloat = Float.valueOf("999999999f"); double myDouble = 999999999d; - assertThat(myFloat.intValue()).isEqualTo( - Integer.valueOf(String.valueOf(myDouble))); + assertEquals(myFloat, myDouble, 1d); } @Test @@ -105,15 +106,13 @@ void playingWithBigDecimal() { assertThat(multiply).isEqualTo(reduce); } - - @EnabledOnOs(OS.MAC) @Test void whenIncrementalReturnCorrectValue() { // Given final CustomizedNumber customizedNumber = new CustomizedNumber(); AtomicInteger atomicInteger = new AtomicInteger(); - final ExecutorService executorService = Executors.newFixedThreadPool(5); + final ExecutorService executorService = Executors.newFixedThreadPool(THREADS); long max = 100_000L; // When LongStream.range(0, max) @@ -142,7 +141,7 @@ void testDoubleAdder() { // Given final CustomizedNumber customizedNumber = new CustomizedNumber(); DoubleAdder doubleAdder = new DoubleAdder(); - final ExecutorService executorService = Executors.newFixedThreadPool(5); + final ExecutorService executorService = Executors.newFixedThreadPool(THREADS); long max = 100_000L; // When @@ -184,7 +183,7 @@ void testIncrementValues() { customizedNumber.longPrimitiveIncrement(); // Primitive }); } - Throwable throwable = catchThrowable(() -> executorService.awaitTermination(5, TimeUnit.SECONDS)); + Throwable throwable = catchThrowable(() -> executorService.awaitTermination(THREADS, TimeUnit.SECONDS)); // Then assertAll(() -> {