Merge pull request #8462 from eugenp/BAEL-3517
BAEL-3517: Code Review Feedback Applied
This commit is contained in:
commit
65a461f702
|
@ -3,7 +3,6 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>java-numbers-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>java-numbers-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -13,7 +12,6 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
<build>
|
||||
<finalName>java-numbers-3</finalName>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package com.baeldung.doubletolong;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DoubleToLongUnitTest {
|
||||
|
||||
final static double VALUE = 9999.999;
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenLongValueCalled_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, Double.valueOf(VALUE)
|
||||
.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathRoundUseds_thenLongValueReturned() {
|
||||
Assert.assertEquals(10000L, Math.round(VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathCeilUsed_thenLongValueReturned() {
|
||||
Assert.assertEquals(10000L, Math.ceil(VALUE), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathFloorUsed_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, Math.floor(VALUE), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenTypeCasted_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, (long) VALUE);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.baeldung.doubletolong;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DoubleToLongUnitTest {
|
||||
|
||||
final static double VALUE = 9999.999;
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenLongValueCalled_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, Double.valueOf(VALUE).longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathRoundUsed_thenRoundUp() {
|
||||
Assert.assertEquals(10000L, Math.round(VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathRoundUsed_thenRoundDown() {
|
||||
Assert.assertEquals(9999L, Math.round(9999.444));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathRoundUsed_thenSameValueReturned() {
|
||||
Assert.assertEquals(9999L, Math.round(9999.0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathCeilUsed_thenLongValueReturned() {
|
||||
Assert.assertEquals(10000L, Math.ceil(VALUE), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathCeilUsed_thenSameValueReturned() {
|
||||
Assert.assertEquals(9999L, Math.ceil(9999.0), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathCeilUsed_thenDifferentThanRound() {
|
||||
Assert.assertEquals(10000L, Math.ceil(9999.444), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathFloorUsed_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, Math.floor(VALUE), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathFloorUsed_thenSameValueReturned() {
|
||||
Assert.assertEquals(9999L, Math.floor(9999.0), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenMathFloorUsed_thenDifferentThanCeil() {
|
||||
Assert.assertEquals(9999L, Math.floor(9999.444), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDoubleValue_whenTypeCasted_thenLongValueReturned() {
|
||||
Assert.assertEquals(9999L, (long) VALUE);
|
||||
}
|
||||
}
|
2
pom.xml
2
pom.xml
|
@ -512,6 +512,7 @@
|
|||
<module>java-math-2</module> <!-- Added for BAEL-3506 -->
|
||||
<module>java-numbers</module>
|
||||
<module>java-numbers-2</module>
|
||||
<module>java-numbers-3</module>
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>java-vavr-stream</module>
|
||||
|
@ -1146,6 +1147,7 @@
|
|||
<module>java-math-2</module> <!-- Added for BAEL-3506 -->
|
||||
<module>java-numbers</module>
|
||||
<module>java-numbers-2</module>
|
||||
<module>java-numbers-3</module>
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>java-vavr-stream</module>
|
||||
|
|
Loading…
Reference in New Issue