Skip to content

Commit

Permalink
Enable Float test
Browse files Browse the repository at this point in the history
Extract number of threads to constant
  • Loading branch information
luizgustavocosta committed Mar 15, 2021
1 parent f995de2 commit 5df550e
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(() -> {
Expand Down

0 comments on commit 5df550e

Please sign in to comment.