Added tests for NumberUtilsTest
This commit is contained in:
16
build.gradle
16
build.gradle
@@ -61,6 +61,10 @@ allprojects {
|
|||||||
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
testCompileOnly 'org.projectlombok:lombok:1.18.20'
|
testCompileOnly 'org.projectlombok:lombok:1.18.20'
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
|
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
|
|
||||||
|
// Test
|
||||||
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
|
||||||
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
@@ -96,6 +100,18 @@ allprojects {
|
|||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
// Always run tests, even when nothing changed.
|
||||||
|
dependsOn cleanTest
|
||||||
|
|
||||||
|
// Show test results.
|
||||||
|
testLogging {
|
||||||
|
events "passed", "skipped", "failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
compileJava.dependsOn clean
|
compileJava.dependsOn clean
|
||||||
|
|
||||||
|
|||||||
24
eco-api/src/test/java/NumberUtilsTest.java
Normal file
24
eco-api/src/test/java/NumberUtilsTest.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import com.willfp.eco.util.NumberUtils;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class NumberUtilsTest {
|
||||||
|
@Test
|
||||||
|
public void testFormatDouble() {
|
||||||
|
Assertions.assertEquals(NumberUtils.format(3.0D), "3");
|
||||||
|
Assertions.assertEquals(NumberUtils.format(3.2D), "3.20");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLog2() {
|
||||||
|
Assertions.assertEquals(NumberUtils.log2(2), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNumerals() {
|
||||||
|
Assertions.assertEquals(NumberUtils.fromNumeral("IV"), 4);
|
||||||
|
Assertions.assertEquals(NumberUtils.fromNumeral("IX"), 9);
|
||||||
|
Assertions.assertEquals(NumberUtils.toNumeral(14), "XIV");
|
||||||
|
Assertions.assertEquals(NumberUtils.toNumeral(21), "XXI");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user