add first unit tests
the ci has always had a 'mvn test' step, but there was nothing to test. add junit 6 and pin surefire 3.6.0, extract the os detection into a testable fromOsName method, and cover the movement step math - including the axis-aligned cases that used to produce infinite steps and never converge.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package wtf.beatrice.autosqueal.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class SystemUtilTest
|
||||
{
|
||||
@Test
|
||||
void detectsWindows() {
|
||||
assertEquals(SystemUtil.OperatingSystem.WINDOWS, SystemUtil.fromOsName("Windows 11"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void detectsLinux() {
|
||||
assertEquals(SystemUtil.OperatingSystem.LINUX, SystemUtil.fromOsName("Linux"));
|
||||
assertEquals(SystemUtil.OperatingSystem.LINUX, SystemUtil.fromOsName("GNU/Linux"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void detectsMacOS() {
|
||||
assertEquals(SystemUtil.OperatingSystem.MAC_OS, SystemUtil.fromOsName("Mac OS X"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownForOtherSystems() {
|
||||
assertEquals(SystemUtil.OperatingSystem.UNKNOWN, SystemUtil.fromOsName("SunOS"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostSystemMatchesOsName() {
|
||||
assertEquals(SystemUtil.fromOsName(System.getProperty("os.name")), SystemUtil.getHostSystem());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user