FC18: Fixed NCR encoding and added full range for six bit computers
This commit is contained in:
parent
d0cf13fe26
commit
e7e26b569b
10 changed files with 312 additions and 160 deletions
|
|
@ -53,29 +53,60 @@ public class FourCornerRecipeTest {
|
|||
Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRValues() throws Exception {
|
||||
List<Integer> cdcX06 = new ArrayList<>();
|
||||
List<Integer> cdcX18 = new ArrayList<>();
|
||||
BigInteger v1 = BigInteger.valueOf(123);
|
||||
FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v1, BigInteger.ONE);
|
||||
FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v1, BigInteger.ONE);
|
||||
BigInteger v2 = BigInteger.valueOf(12345);
|
||||
FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v2, BigInteger.ONE);
|
||||
FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v2, BigInteger.ONE);
|
||||
System.out.println(FourCornerUnicodeDisplay.raw().renderFromInt18(cdcX06));
|
||||
String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX06);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX18);
|
||||
Assertions.assertEquals(resX18, resX06);
|
||||
Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅", resX06);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRCount1024() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
for (int x = 1; x <= 1024; x++) {
|
||||
List<Integer> cdcX06 = new ArrayList<>();
|
||||
List<Integer> cdcX18 = new ArrayList<>();
|
||||
for (int x = 1; x <= 1025; x++) {
|
||||
BigInteger v = BigInteger.valueOf(x);
|
||||
cdc.addAll(FourCornerRecipe.embedNCR1632Denominator(v));
|
||||
|
||||
//cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // NXX_1
|
||||
List<Integer> nomList = FourCornerRecipe.embedNCR1632Numerator(BigInteger.ONE);
|
||||
Assertions.assertEquals(1, nomList.size());
|
||||
cdc.addAll(nomList); // NXX_1
|
||||
FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v, BigInteger.ONE);
|
||||
FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v, BigInteger.ONE);
|
||||
}
|
||||
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
|
||||
Assertions.assertTrue(res.startsWith("¹/₁¹/₂"), "missing " + res);
|
||||
Assertions.assertTrue(res.endsWith("¹/₁₀₂₃¹/₁₀₂₄"), "missing " + res);
|
||||
System.out.println(FourCornerUnicodeDisplay.raw().renderFromInt18(cdcX06));
|
||||
String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX06);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX18);
|
||||
Assertions.assertEquals(resX18, resX06);
|
||||
Assertions.assertTrue(resX06.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX06);
|
||||
Assertions.assertTrue(resX06.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX06);
|
||||
Assertions.assertTrue(resX06.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX06);
|
||||
Assertions.assertTrue(resX18.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX18);
|
||||
Assertions.assertTrue(resX18.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX18);
|
||||
Assertions.assertTrue(resX18.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX18);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRMaxValue() throws Exception {
|
||||
BigInteger maxValue = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
FourCornerRecipe.embedNCR1632Numerator(maxValue);
|
||||
FourCornerRecipe.embedNCR1632FractionX06(maxValue, maxValue);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
FourCornerRecipe.embedNCR1632Numerator(maxValue.add(BigInteger.ONE));
|
||||
FourCornerRecipe.embedNCR1632FractionX06(maxValue.add(BigInteger.ONE), maxValue);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
FourCornerRecipe.embedNCR1632FractionX06(maxValue, maxValue.add(BigInteger.ONE));
|
||||
});
|
||||
FourCornerRecipe.embedNCR1632FractionX18(maxValue, maxValue);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
FourCornerRecipe.embedNCR1632FractionX18(maxValue.add(BigInteger.ONE), maxValue);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
FourCornerRecipe.embedNCR1632FractionX18(maxValue, maxValue.add(BigInteger.ONE));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.fc18;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,13 @@
|
|||
*/
|
||||
package org.x4o.fc18.zion7;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.x4o.fc18.FourCornerUnicodeDisplay;
|
||||
import org.x4o.fc18.FourCornerRecipe;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||
|
||||
|
|
@ -62,7 +59,6 @@ public class LexerNCRTest {
|
|||
lexer.read(cdc);
|
||||
Assertions.assertEquals(2, fireWalker.ncr1632BankSparkler);
|
||||
|
||||
Assertions.assertEquals(0, fireWalker.ncr1632BankReset);
|
||||
cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.cakePointSequence()); // the print above auto value + next test (normal bank reset)
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 11);
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + (512*3) + 12);
|
||||
|
|
@ -74,30 +70,8 @@ public class LexerNCRTest {
|
|||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // normal NXX_123
|
||||
fireWalker.reset();
|
||||
lexer.read(cdc);
|
||||
Assertions.assertEquals(1, fireWalker.ncr1632BankReset);
|
||||
|
||||
Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇¹²³/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRSimpleX06() throws Exception {
|
||||
List<FourCornerX06BaklavaPointSequence> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.NY09_EQUALS);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X2);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X3);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X2);
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // T015
|
||||
cdc.add(FCDotCDC1604DashP6.NX14_N); // NXX_014
|
||||
cdc.add(FCDotCDC1604DashP6.NX05_E); // NXX_005
|
||||
cdc.add(FCDotCDC1604DashP6.NX07_G); // NXX_007
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // NXX_015
|
||||
cdc.add(FCDotCDC1604DashP6.NX04_D); // NXX_004
|
||||
//cdc.add(FCDotCDC1604DashP6.NY14_SEMICOLON);
|
||||
//cdc.add(FCDotCDC1604DashP6._NEWLINE);
|
||||
|
||||
Assertions.assertEquals("X=¹⁴/₁₅⁵/₁₅⁷/₁₅¹⁵/₁₅⁴/₁₅", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
|
||||
Assertions.assertEquals("X=␇␘␇ONEGOD", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
|
||||
String res = "¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁴⁷³/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇²⁴⁶⁸⁴⁷³³⁴²⁸²⁷²⁷³⁷⁶⁷⁶⁷⁴¹⁵⁶⁰²⁰³³²⁸⁰⁶⁹¹⁶¹⁷⁰⁹³⁹⁸³¹⁸⁴⁹⁹⁸⁵³⁵⁵³⁹²³⁰⁹⁰¹⁶⁸⁶⁴⁶⁵⁷⁸⁵²¹³⁷⁴⁵⁶⁷²¹¹⁷²⁴⁹³⁷⁶⁸⁴⁰⁴²⁰³⁰⁴⁶⁶⁷³⁵²³⁶³⁴⁷⁴⁰¹²²⁰¹⁵⁶⁷²⁰⁴¹⁹⁴³⁹⁹⁴⁷⁴¹²⁰⁸³⁶⁵¹⁰⁵⁷⁸²⁹¹⁵¹⁷⁷⁰⁹⁷⁸²⁸²³⁰¹⁹⁶⁴⁹⁵⁴⁶⁸⁴⁶³³¹/₁";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -113,11 +87,11 @@ public class LexerNCRTest {
|
|||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 1); // one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 512 + 2); // T1024 + one
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // NXX_123
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 4); // NXX_004
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 4); // NXX_004 (/1 as above 123 resets bank)
|
||||
cdc.add(FCDotCDC1604DashP6.NY14_SEMICOLON.ordinal());
|
||||
//cdc.add(FCDotCDC1604DashP6._NEWLINE.ordinal());
|
||||
|
||||
Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁₀₂₅;", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁;", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
int scanBlockStop;
|
||||
int scanMatchPoint;
|
||||
int ncr1632BankSparkler;
|
||||
int ncr1632BankReset;
|
||||
|
||||
public TestFireWalker() {
|
||||
reset();
|
||||
|
|
@ -47,7 +46,6 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
scanMatchPoint = 0;
|
||||
scanMatchPoint = 0;
|
||||
ncr1632BankSparkler = 0;
|
||||
ncr1632BankReset = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,11 +66,4 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
ncr1632BankSparkler++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireStateNCR1632BankReset(boolean magic) {
|
||||
if (magic) {
|
||||
ncr1632BankReset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue