Moved numberxd to libary and added some unit tests.

This commit is contained in:
Willem Cazander 2022-01-31 15:03:30 +01:00
parent af627bbd06
commit 444ced9ee2
70 changed files with 427 additions and 6 deletions

9
.gitignore vendored
View file

@ -2,11 +2,10 @@
# Ignore files in the demo4D project.
#
# Ignore project resources
core/bin
desktop/bin
# Ignore gradle work folder
# Ignore gradle resources
bin
build
.gitignore
.gradle
# Ignore binary files and formats

View file

@ -19,6 +19,7 @@ allprojects {
gdxVersion = "1.10.0"
spairVersion = "1.86.0"
nativefilechooserVersion = "1.0.0"
junitVersion = "5.7.2"
}
repositories {
mavenLocal()
@ -32,6 +33,17 @@ allprojects {
}
}
project(":numberxd") {
apply plugin: "java-library"
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
//api "org.x4o:x4o-driver:$x4oVersion"
}
tasks.named('test') {
useJUnitPlatform()
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
@ -46,6 +58,7 @@ project(":core") {
apply plugin: "java-library"
dependencies {
//api "org.x4o:x4o-driver:$x4oVersion"
api project(":numberxd")
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "io.github.spair:imgui-java-binding:$spairVersion"
api "io.github.spair:imgui-java-lwjgl3:$spairVersion"

6
numberxd/build.gradle Normal file
View file

@ -0,0 +1,6 @@
sourceCompatibility = appJvmCode
[compileJava, compileTestJava]*.options*.encoding = appEncoding
sourceSets.main.java.srcDirs = [ "src/main/", "src/resources/" ]
eclipse.project.name = appName + "-numberxd"

View file

@ -28,6 +28,8 @@ public enum T05PartPental implements BasePart {
private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
private static final Map<String, T05PartPental> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T05PartPental> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private T05PartPental(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
@ -50,4 +52,8 @@ public enum T05PartPental implements BasePart {
public static T05PartPental valueOfTone(String identifierTone) {
return TONE_MAP.get(identifierTone);
}
public static T05PartPental valueOfChina(String chinaKey) {
return CHINA_MAP.get(chinaKey);
}
}

View file

@ -0,0 +1,34 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T02PartBinaryTest {
@Test
public void testBasePart() {
for (T02PartBinary value:T02PartBinary.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T02PartBinary.PART_1, T02PartBinary.valueOfTone("˧"));
Assertions.assertEquals(T02PartBinary.PART_2, T02PartBinary.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T02PartBinary.PART_1, T02PartBinary.valueOfChina(""));
Assertions.assertEquals(T02PartBinary.PART_2, T02PartBinary.valueOfChina(""));
}
}

View file

@ -0,0 +1,36 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T03PartTritTest {
@Test
public void testBasePart() {
for (T03PartTrit value:T03PartTrit.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T03PartTrit.PART_1, T03PartTrit.valueOfTone("˦"));
Assertions.assertEquals(T03PartTrit.PART_2, T03PartTrit.valueOfTone("˧"));
Assertions.assertEquals(T03PartTrit.PART_3, T03PartTrit.valueOfTone("˨"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T03PartTrit.PART_1, T03PartTrit.valueOfChina(""));
Assertions.assertEquals(T03PartTrit.PART_2, T03PartTrit.valueOfChina(""));
Assertions.assertEquals(T03PartTrit.PART_3, T03PartTrit.valueOfChina(""));
}
}

View file

@ -0,0 +1,41 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T04PartQuadTest {
@Test
public void testBasePart() {
for (T04PartQuad value:T04PartQuad.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T04PartQuad.PART_1, T04PartQuad.valueOfTone("˥"));
Assertions.assertEquals(T04PartQuad.PART_2, T04PartQuad.valueOfTone(""));
Assertions.assertEquals(T04PartQuad.PART_3, T04PartQuad.valueOfTone(""));
Assertions.assertEquals(T04PartQuad.PART_4, T04PartQuad.valueOfTone("˩"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T04PartQuad.PART_1, T04PartQuad.valueOfChina(""));
Assertions.assertEquals(T04PartQuad.PART_2, T04PartQuad.valueOfChina(""));
Assertions.assertEquals(T04PartQuad.PART_3, T04PartQuad.valueOfChina("西"));
Assertions.assertEquals(T04PartQuad.PART_4, T04PartQuad.valueOfChina(""));
}
}

View file

@ -0,0 +1,40 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T05PartPentalTest {
@Test
public void testBasePart() {
for (T05PartPental value:T05PartPental.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T05PartPental.PART_1, T05PartPental.valueOfTone("˥"));
Assertions.assertEquals(T05PartPental.PART_2, T05PartPental.valueOfTone("˦"));
Assertions.assertEquals(T05PartPental.PART_3, T05PartPental.valueOfTone("˧"));
Assertions.assertEquals(T05PartPental.PART_4, T05PartPental.valueOfTone("˨"));
Assertions.assertEquals(T05PartPental.PART_5, T05PartPental.valueOfTone("˩"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T05PartPental.PART_1, T05PartPental.valueOfChina(""));
Assertions.assertEquals(T05PartPental.PART_2, T05PartPental.valueOfChina(""));
Assertions.assertEquals(T05PartPental.PART_3, T05PartPental.valueOfChina(""));
Assertions.assertEquals(T05PartPental.PART_4, T05PartPental.valueOfChina(""));
Assertions.assertEquals(T05PartPental.PART_5, T05PartPental.valueOfChina(""));
}
}

View file

@ -0,0 +1,41 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T06PartSeximalTest {
@Test
public void testBasePart() {
for (T06PartSeximal value:T06PartSeximal.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T06PartSeximal.PART_1, T06PartSeximal.valueOfTone("˦"));
Assertions.assertEquals(T06PartSeximal.PART_2, T06PartSeximal.valueOfTone("˨"));
Assertions.assertEquals(T06PartSeximal.PART_5, T06PartSeximal.valueOfTone(""));
Assertions.assertEquals(T06PartSeximal.PART_6, T06PartSeximal.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T06PartSeximal.PART_1, T06PartSeximal.valueOfChina(""));
Assertions.assertEquals(T06PartSeximal.PART_2, T06PartSeximal.valueOfChina(""));
Assertions.assertEquals(T06PartSeximal.PART_5, T06PartSeximal.valueOfChina(""));
Assertions.assertEquals(T06PartSeximal.PART_6, T06PartSeximal.valueOfChina(""));
}
}

View file

@ -0,0 +1,44 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T08PartOctalTest {
@Test
public void testBasePart() {
for (T08PartOctal value:T08PartOctal.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
Assertions.assertNotNull(value.getAlt2Value());
Assertions.assertNotNull(value.getAlt2Name());
Assertions.assertNotNull(value.getAlt2Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T08PartOctal.PART_1, T08PartOctal.valueOfTone("˥"));
Assertions.assertEquals(T08PartOctal.PART_2, T08PartOctal.valueOfTone("˩"));
Assertions.assertEquals(T08PartOctal.PART_7, T08PartOctal.valueOfTone(""));
Assertions.assertEquals(T08PartOctal.PART_8, T08PartOctal.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T08PartOctal.PART_1, T08PartOctal.valueOfChina(""));
Assertions.assertEquals(T08PartOctal.PART_2, T08PartOctal.valueOfChina(""));
Assertions.assertEquals(T08PartOctal.PART_7, T08PartOctal.valueOfChina(""));
Assertions.assertEquals(T08PartOctal.PART_8, T08PartOctal.valueOfChina(""));
}
}

View file

@ -0,0 +1,41 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T12PartUncialTest {
@Test
public void testBasePart() {
for (T12PartUncial value:T12PartUncial.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T12PartUncial.PART_1, T12PartUncial.valueOfTone("˥"));
Assertions.assertEquals(T12PartUncial.PART_2, T12PartUncial.valueOfTone("˧"));
Assertions.assertEquals(T12PartUncial.PART_11, T12PartUncial.valueOfTone(""));
Assertions.assertEquals(T12PartUncial.PART_12, T12PartUncial.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T12PartUncial.PART_1, T12PartUncial.valueOfChina(""));
Assertions.assertEquals(T12PartUncial.PART_2, T12PartUncial.valueOfChina(""));
Assertions.assertEquals(T12PartUncial.PART_11, T12PartUncial.valueOfChina(""));
Assertions.assertEquals(T12PartUncial.PART_12, T12PartUncial.valueOfChina(""));
}
}

View file

@ -0,0 +1,41 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T16PartHexTest {
@Test
public void testBasePart() {
for (T16PartHex value:T16PartHex.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T16PartHex.PART_1, T16PartHex.valueOfTone("˥"));
Assertions.assertEquals(T16PartHex.PART_2, T16PartHex.valueOfTone("˦"));
Assertions.assertEquals(T16PartHex.PART_15, T16PartHex.valueOfTone(""));
Assertions.assertEquals(T16PartHex.PART_16, T16PartHex.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T16PartHex.PART_1, T16PartHex.valueOfChina(""));
Assertions.assertEquals(T16PartHex.PART_2, T16PartHex.valueOfChina(""));
Assertions.assertEquals(T16PartHex.PART_15, T16PartHex.valueOfChina(""));
Assertions.assertEquals(T16PartHex.PART_16, T16PartHex.valueOfChina(""));
}
}

View file

@ -0,0 +1,41 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T20PartScoreTest {
@Test
public void testBasePart() {
for (T20PartScore value:T20PartScore.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
Assertions.assertNotNull(value.getAlt1Value());
Assertions.assertNotNull(value.getAlt1Name());
Assertions.assertNotNull(value.getAlt1Wiki());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T20PartScore.PART_1, T20PartScore.valueOfTone("˥"));
Assertions.assertEquals(T20PartScore.PART_2, T20PartScore.valueOfTone("˦"));
Assertions.assertEquals(T20PartScore.PART_19, T20PartScore.valueOfTone(""));
Assertions.assertEquals(T20PartScore.PART_20, T20PartScore.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T20PartScore.PART_1, T20PartScore.valueOfChina(""));
Assertions.assertEquals(T20PartScore.PART_2, T20PartScore.valueOfChina(""));
Assertions.assertEquals(T20PartScore.PART_19, T20PartScore.valueOfChina(""));
Assertions.assertEquals(T20PartScore.PART_20, T20PartScore.valueOfChina(""));
}
}

View file

@ -0,0 +1,38 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T60SexagesimalTest {
@Test
public void testBasePart() {
for (T60Sexagesimal value:T60Sexagesimal.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.valueOfTone("˧˩˥"));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.valueOfTone("˧˥˦"));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.valueOfTone("꜍꜍꜏"));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.valueOfTone("꜑꜑꜏"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T60Sexagesimal.PART_1, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_2, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_59, T60Sexagesimal.valueOfChina(""));
Assertions.assertEquals(T60Sexagesimal.PART_60, T60Sexagesimal.valueOfChina(""));
}
}

View file

@ -1 +1 @@
include 'desktop', 'core'
include 'desktop', 'core', 'numberxd'