From d41af20079d46443c609be4ee36f326c97f98512 Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 25 Aug 2025 19:09:20 +0200 Subject: [PATCH] FC18: Made NCR signed and added Dozeger 192 bit integer support --- .../java/org/x4o/fc18/FourCornerRecipe.java | 34 +++++++-- .../x4o/fc18/FourCornerUnicodeDisplay.java | 25 +++++++ .../fc18/zion7/FourCornerZion7Candlelier.java | 17 ++++- .../zion7/FourCornerZion7Petroglyphs.java | 5 +- .../zion7/FourCornerZionStenoGrapher.java | 72 ++++++++++++++++--- .../fc18/zion7/FourCornerZionStenoLexer.java | 71 +++++++++++++++++- .../zion7/FourCornerZionStenoLexerSmoke.java | 18 +++-- .../fc18/FourCornerUnicodeDisplayTest.java | 4 +- .../org/x4o/fc18/zion7/StenoGrapherTest.java | 20 +++++- .../org/x4o/fc18/zion7/StenoLexerNCRTest.java | 8 +-- 10 files changed, 241 insertions(+), 33 deletions(-) diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java index 2f03b7c..4f16ce9 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java @@ -139,30 +139,50 @@ final public class FourCornerRecipe { } static public List toDecimalsX06(int value) { - return toDecimalsX00(new ArrayList<>(), value, true); + return toDecimalsX00(new ArrayList<>(), Integer.toString(value), true); } static public List toDecimalsX18(int value) { - return toDecimalsX00(new ArrayList<>(), value, false); + return toDecimalsX00(new ArrayList<>(), Integer.toString(value), false); } static public void toDecimalsX06(List out, int value) { - toDecimalsX00(out, value, true); + toDecimalsX00(out, Integer.toString(value), true); } static public void toDecimalsX18(List out, int value) { - toDecimalsX00(out, value, false); + toDecimalsX00(out, Integer.toString(value), false); } - static private List toDecimalsX00(List out, int value, boolean isSixBit) { - String valueStr = Integer.toString(value); - PrimitiveIterator.OfInt i = valueStr.codePoints().iterator(); + static public List toDecimalsX06(BigInteger value) { + return toDecimalsX00(new ArrayList<>(), value.toString(10), true); + } + + static public List toDecimalsX18(BigInteger value) { + return toDecimalsX00(new ArrayList<>(), value.toString(10), false); + } + + static public void toDecimalsX06(List out, BigInteger value) { + toDecimalsX00(out, value.toString(10), true); + } + + static public void toDecimalsX18(List out, BigInteger value) { + toDecimalsX00(out, value.toString(10), false); + } + + static private List toDecimalsX00(List out, String value, boolean isSixBit) { + boolean negative = value.startsWith("-"); + String valueClean = value.replaceAll("-", ""); + PrimitiveIterator.OfInt i = valueClean.codePoints().iterator(); boolean first = true; while (i.hasNext()) { int chr = i.nextInt(); int num = chr - '0'; if (first) { first = false; // Add escaping only once for six bit mode + if (negative) { + out.add(FCDotCDC1604DashP6.NY19_MINUS.ordinal()); + } if (isSixBit) { out.addAll(FCDotPIE9CDash10.valueOf(num).baklavaPointSequence()); } else { diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java index f0f4ed2..f1ed3ea 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java @@ -22,6 +22,7 @@ */ package org.x4o.fc18; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; @@ -251,6 +252,30 @@ public class FourCornerUnicodeDisplay { renderFromInt18(math, output); } + @Override + public void strobeNumberDozeger(BigInteger value) { + List numberCandy = new ArrayList<>(); + FourCornerRecipe.toDecimalsX18(numberCandy, value); + renderFromInt18(numberCandy, output); + } + + @Override + public void strobeNumberDozimal(BigDecimal value) { + List numberCandy = new ArrayList<>(); + FourCornerRecipe.toDecimalsX18(numberCandy, value.unscaledValue()); + numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal()); + numberCandy.add(FCDotCDC1604DashP6.NX16_P.ordinal()); + numberCandy.add(FCDotCDC1604DashP6.NX15_O.ordinal()); + numberCandy.add(FCDotCDC1604DashP6.NX23_W.ordinal()); + numberCandy.add(FCDotCDC1604DashP6.NY25_ROUND_LEFT.ordinal()); + numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal()); + FourCornerRecipe.toDecimalsX18(numberCandy, 1); + FourCornerRecipe.toDecimalsX18(numberCandy, 0); + FourCornerRecipe.toDecimalsX18(numberCandy, value.scale()); + numberCandy.add(FCDotCDC1604DashP6.NY24_ROUND_RIGHT.ordinal()); + renderFromInt18(numberCandy, output); + } + @Override public void strobeNCR1632(BigInteger numerator, BigInteger denominator) { List math = new ArrayList<>(); diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java index 02c4663..34a3c89 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java @@ -22,6 +22,7 @@ */ package org.x4o.fc18.zion7; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.List; @@ -41,8 +42,12 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { /// Block of one of more number grams of given base. void strobeNumberGrams(FourCornerZion7NumberGram gram, List values); - //void strobeNumberDozimal(BigDecimal value); - //void strobeNumberDozeger(BigInteger value); // up to 192 bit integer + + /// Embed signed integer up to 192 bit + void strobeNumberDozeger(BigInteger value); + + /// Embed signed decimal up to 192 bit + void strobeNumberDozimal(BigDecimal value); /// 1152 bit fractions of two 576 bit numbers. void strobeNCR1632(BigInteger numerator, BigInteger denominator); @@ -70,6 +75,14 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { default void strobeNumberGrams(FourCornerZion7NumberGram gram, List values) { } + @Override + default void strobeNumberDozeger(BigInteger value) { + } + + @Override + default void strobeNumberDozimal(BigDecimal value) { + } + @Override default void strobeNCR1632(BigInteger numerator, BigInteger denominator) { } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java index b6ec672..bcc584d 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java @@ -31,8 +31,11 @@ import java.util.List; /// @version 1.0 Aug 24, 2025 public final class FourCornerZion7Petroglyphs { + public static final BigInteger DOZEGER192_MASK_PAGE = BigInteger.valueOf(0b111); + public static final BigInteger DOZEGER192_VALUE_MAX = new BigInteger("7FFFFFFFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFFFFFFFF", 16); + public static final BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF); - public static final BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); + public static final BigInteger NCR1632_VALUE_MAX = new BigInteger("7FFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); public static final List SAND_WORM_SIGN = List.of(24,48,72,96,120,144,168,192); private FourCornerZion7Petroglyphs() { diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java index 82aa94c..ef2d32d 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java @@ -24,6 +24,7 @@ package org.x4o.fc18.zion7; import java.io.IOException; import java.io.OutputStream; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Iterator; @@ -143,7 +144,7 @@ public class FourCornerZionStenoGrapher { Objects.requireNonNull(gram); Objects.requireNonNull(values); if (isSixBit) { - // todo + // TODO } int gramCount = values.size(); for (int i = 0; i < gramCount; i++) { @@ -154,11 +155,42 @@ public class FourCornerZionStenoGrapher { if (gramValue > gram.cutCount()) { throw new IllegalArgumentException("Gram value is greater than cut count: " + gram.cutCount()); } - strobeWord(gram.cutZeroCakePoint() + gramValue); + outAdd(gram.cutZeroCakePoint() + gramValue); } outFlush(); } + @Override + public void strobeNumberDozeger(BigInteger value) { + Objects.requireNonNull(value); + if (value.compareTo(FourCornerZion7Petroglyphs.DOZEGER192_VALUE_MAX) > 0) { + throw new IllegalArgumentException("Value dozeger is larger than 192 bit: " + value); + } + BigInteger valuePos = value; + boolean negative = false; + if (value.signum() == -1) { + valuePos = value.negate(); + negative = true; + } + for (int i = 63; i >= 0; i--) { + int bankValue = valuePos.shiftRight(i * 3).and(FourCornerZion7Petroglyphs.DOZEGER192_MASK_PAGE).intValue(); + if (i == 63 && negative) { + bankValue = (bankValue & 0b011) + 4; + } + if (bankValue == 0 && i > 0) { + continue; + } + int cakePoint = FourCornerDotCake.FC_DOZEGER_192.getStart() + bankValue + (i * 8); + outAdd(cakePoint); + } + outFlush(); + } + + @Override + public void strobeNumberDozimal(BigDecimal value) { + Objects.requireNonNull(value); + } + @Override public void strobeNCR1632(BigInteger numerator, BigInteger denominator) { Objects.requireNonNull(numerator); @@ -166,20 +198,31 @@ public class FourCornerZionStenoGrapher { if (denominator.equals(BigInteger.ZERO)) { // 0/1 = zero but 1/0 is NaN throw new IllegalArgumentException("The denominator value ZERO is not allowed."); } - //if (denominator.signum() == -1) { - // // TODO: check if we need one octal for pos/neg/qNaN/sNaN/pos_inf/neg_inf/free/free options - //} if (numerator.compareTo(FourCornerZion7Petroglyphs.NCR1632_VALUE_MAX) > 0) { throw new IllegalArgumentException("Value numerator is larger than 576 bit: " + numerator); } if (denominator.compareTo(FourCornerZion7Petroglyphs.NCR1632_VALUE_MAX) > 0) { throw new IllegalArgumentException("Value denominator is larger than 576 bit: " + denominator); } - + BigInteger numeratorPos = numerator; + boolean numeratorNegative = false; + if (numerator.signum() == -1) { + numeratorPos = numerator.negate(); + numeratorNegative = true; + } + BigInteger denominatorPos = denominator; + boolean denominatorNegative = false; + if (denominator.signum() == -1) { + denominatorPos = denominator.negate(); + denominatorNegative = true; + } if (isSixBit) { outAddAll(FCDotDEC2701DashPX0.ESC68_NCR.baklavaPointSequence()); for (int i = 63; i >= 0; i--) { - int bankValue = numerator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + int bankValue = numeratorPos.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + if (i == 63 && numeratorNegative) { + bankValue = (bankValue & 0b011) + 4; + } if (bankValue == 0 && i > 0) { continue; } @@ -208,7 +251,10 @@ public class FourCornerZionStenoGrapher { outAdd(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueLSB); } for (int i = 63; i >= 0; i--) { - int bankValue = denominator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + int bankValue = denominatorPos.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + if (i == 63 && denominatorNegative) { + bankValue = (bankValue & 0b011) + 4; + } if (bankValue == 0 && i > 0) { continue; } @@ -241,7 +287,10 @@ public class FourCornerZionStenoGrapher { return; } for (int i = 63; i >= 0; i--) { - int bankValue = numerator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + int bankValue = numeratorPos.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + if (i == 63 && numeratorNegative) { + bankValue = (bankValue & 0b011) + 4; + } if (bankValue == 0 && i > 0) { continue; } @@ -249,7 +298,10 @@ public class FourCornerZionStenoGrapher { outAdd(cakePoint); } for (int i = 63; i >= 0; i--) { - int bankValue = denominator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + int bankValue = denominatorPos.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); + if (i == 63 && denominatorNegative) { + bankValue = (bankValue & 0b011) + 4; + } if (bankValue == 0 && i > 0) { continue; } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java index 92397d2..1b41bee 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java @@ -87,6 +87,12 @@ public class FourCornerZionStenoLexer { if (FourCornerDotCake.FC_SANDWORM_15.equals(cakeSlice)) { continue; // parse nether body manually } + if (FourCornerDotCake.FC_DOZEGER_192.equals(cakeSlice)) { + continue; // parse block manually + } + if (FourCornerDotCake.FC_DOZIMAL_192.equals(cakeSlice)) { + continue; // parse block manually + } if (FourCornerDotCake.FC_NCR1632_DEN.equals(cakeSlice)) { continue; // parse block manually } @@ -100,6 +106,7 @@ public class FourCornerZionStenoLexer { CAKE_SLICE_EATERS.add(new StenoScannerWordCakeSlice(cakeSlice)); } CAKE_SLICE_EATERS.add(new StenoScannerCDCDEC()); + CAKE_SLICE_EATERS.add(new StenoScannerDozeger()); CAKE_SLICE_EATERS.add(new StenoScannerNCR18()); CAKE_SLICE_EATERS.add(new StenoScannerSandWorm()); ArrayList.class.cast(CAKE_SLICE_EATERS).trimToSize(); @@ -194,12 +201,28 @@ public class FourCornerZionStenoLexer { } private void ncrBankFire() { + boolean numeratorNegetive = false; + boolean denominatorNegetive = false; BigInteger numerator = BigInteger.ZERO; BigInteger denominator = BigInteger.ZERO; for (int i = 0; i < numeratorBank.length; i++) { + if (i == 63 && (numeratorBank[i] & 0b100) == 4) { + numeratorNegetive = true; + numeratorBank[i] = numeratorBank[i] & 0b011; + } + if (i == 63 && (denominatorBank[i] & 0b100) == 4) { + denominatorNegetive = true; + denominatorBank[i] = denominatorBank[i] & 0b011; + } numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i * 9)); denominator = denominator.add(BigInteger.valueOf(denominatorBank[i]).shiftLeft(i * 9)); } + if (numeratorNegetive) { + numerator = numerator.negate(); + } + if (denominatorNegetive) { + denominator = denominator.negate(); + } handler.strobeNCR1632(numerator, denominator); // reset the bank after each fire for (int i = 0; i < numeratorBank.length; i++) { @@ -352,6 +375,52 @@ public class FourCornerZionStenoLexer { } } + static class StenoScannerDozeger extends StenoScanner { + + static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_DOZEGER_192.getStart() + 8; + + public StenoScannerDozeger() { + super(FourCornerDotCake.FC_DOZEGER_192); + } + + @Override + public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) { + int valueBank[] = new int[64]; + boolean negetive = false; + boolean missingSparkler = true; + for (int i = idxFirst; i <= idxLast; i++) { + int cakePoint = lexer.input.get(i); + int valueOffset = cakePoint - FourCornerDotCake.FC_DOZEGER_192.getStart(); + int bankSelect = valueOffset / 8; + int bankValue = valueOffset % 8; + if (bankSelect == 63 && (bankValue & 0b100) == 4) { + negetive = true; + bankValue = bankValue & 0b011; // remove sign bit from value + } + valueBank[bankSelect] = bankValue; + if (cakePoint > CAKEPOINT_BANK0_END) { + missingSparkler = true; + continue; // Only fire value on lowest value select + } + BigInteger valueNumber = BigInteger.ZERO; + for (int ii = 0; ii < valueBank.length; ii++) { + valueNumber = valueNumber.add(BigInteger.valueOf(valueBank[ii]).shiftLeft(ii * 3)); + } + if (negetive) { + valueNumber = valueNumber.negate(); + } + lexer.handler.strobeNumberDozeger(valueNumber); + for (int ii = 0; ii < valueBank.length; ii++) { + valueBank[ii] = 0; + } + missingSparkler = false; + } + if (missingSparkler) { + lexer.smokeSignals.burnNumberDozegerMissingSparkler(lexer.currLine, lexer.currCol); + } + } + } + static class StenoScannerNCR18 extends StenoScanner { static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NCR1632_DEN.getStart() + 512; @@ -382,7 +451,7 @@ public class FourCornerZionStenoLexer { missingSparkler = false; } if (missingSparkler) { - lexer.smokeSignals.burnNCR1632MissingBankSparkler(lexer.currLine, lexer.currCol); + lexer.smokeSignals.burnNCR1632MissingSparkler(lexer.currLine, lexer.currCol); } } } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmoke.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmoke.java index a976fef..eea8f3e 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmoke.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmoke.java @@ -42,8 +42,9 @@ public interface FourCornerZionStenoLexerSmoke { void burnSandWalkerStepUnaligned(int line, int col, int size); + void burnNumberDozegerMissingSparkler(int line, int col); - void burnNCR1632MissingBankSparkler(int line, int col); + void burnNCR1632MissingSparkler(int line, int col); interface Adapter extends FourCornerZionStenoLexerSmoke { @@ -72,7 +73,11 @@ public interface FourCornerZionStenoLexerSmoke { } @Override - default void burnNCR1632MissingBankSparkler(int line, int col) { + default void burnNumberDozegerMissingSparkler(int line, int col) { + } + + @Override + default void burnNCR1632MissingSparkler(int line, int col) { } } @@ -111,8 +116,13 @@ public interface FourCornerZionStenoLexerSmoke { } @Override - default void burnNCR1632MissingBankSparkler(int line, int col) { - burnMonoPipe(line, col, "burnNCR1632MissingBankSparkler"); + default void burnNumberDozegerMissingSparkler(int line, int col) { + burnMonoPipe(line, col, "burnNumberDozegerMissingSparkler"); + } + + @Override + default void burnNCR1632MissingSparkler(int line, int col) { + burnMonoPipe(line, col, "burnNCR1632MissingSparkler"); } } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerUnicodeDisplayTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerUnicodeDisplayTest.java index e1ad69d..ac139d2 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerUnicodeDisplayTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerUnicodeDisplayTest.java @@ -213,7 +213,7 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotCDC1604DashP6.NX09_I); // I cdc.add(FCDotDEC2701DashPX0.ESC_DEC0801_E10); cdc.add(FCDotDEC0801DashE10.E10_UWU0101_S1); - cdc.add(FCDotCDC1604DashP6.NX01_A); // tab space + cdc.add(FCDotCDC1604DashP6.NX01_A); // T001__ONE cdc.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION); cdc.add(FCDotCDC1604DashP6.NX08_H); // HOI cdc.add(FCDotCDC1604DashP6.NX15_O); @@ -223,6 +223,6 @@ public class FourCornerUnicodeDisplayTest { cdc.add(FCDotCDC1604DashP6.NX02_B); // B cdc.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION); // with ! as we droped out of escape mode by B being to large - Assertions.assertEquals("HOI1HOIB!", FourCornerUnicodeDisplay.text().renderFromX06(cdc)); + Assertions.assertEquals("HOIT001__ONEHOIB!", FourCornerUnicodeDisplay.text().renderFromX06(cdc)); } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java index ace7e51..e54c69a 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java @@ -35,6 +35,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.x4o.fc18.FourCornerUnicodeDisplay; import org.x4o.fc18.cake2.flag4.FCDotF4TTY0001DashNL; +import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; import org.x4o.fc18.octal8.PrimordialOctal; import org.x4o.fc18.octal8.PrimordialOctalOrangeString; @@ -62,6 +63,18 @@ public class StenoGrapherTest { Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res); } + @Test + public void testDozegerValues() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberDozeger(BigInteger.valueOf(123)); + writerX18.strobeWord(FCDotCDC1604DashP6.NY19_MINUS.ordinal()); + writerX18.strobeNumberDozeger(FourCornerZion7Petroglyphs.DOZEGER192_VALUE_MAX); + writerX18.strobeNumberDozeger(BigInteger.valueOf(-123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("123-3138550867693340381917894711603833208051177722232017256447-123", resX18); + } + @Test public void testNCRValues() throws Exception { List outX06 = new ArrayList<>(); @@ -74,10 +87,13 @@ public class StenoGrapherTest { BigInteger v2 = BigInteger.valueOf(12345); writerX06.strobeNCR1632(BigInteger.ONE, v2); writerX18.strobeNCR1632(BigInteger.ONE, v2); + BigInteger v3 = BigInteger.valueOf(-5432); + writerX06.strobeNCR1632(v3, v3); + writerX18.strobeNCR1632(v3, v3); String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(outX06); String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); Assertions.assertEquals(resX18, resX06); - Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅", resX06); + Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅⁻⁵⁴³²/₋₅₄₃₂", resX06); } //Test TODO: MOVE + fix java.io.IOException: Expected 9 bytes, got: 3 from PrimordialOctalOrangeString.ioSmurfReadStreamX8 @@ -137,7 +153,7 @@ public class StenoGrapherTest { List outX18 = new ArrayList<>(); FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06); FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - BigInteger maxValue = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); + BigInteger maxValue = new BigInteger("7FFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); writerX06.strobeNCR1632(maxValue, maxValue); Assertions.assertThrows(IllegalArgumentException.class, () -> { writerX06.strobeNCR1632(maxValue, maxValue.add(BigInteger.ONE)); diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java index 55cd0a8..cd030b6 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java @@ -51,7 +51,7 @@ public class StenoLexerNCRTest { Assertions.assertEquals(0, smokeReader.pipeSmokeClouds); lexer.read(cdc); Assertions.assertEquals(1, smokeReader.pipeSmokeClouds); - Assertions.assertEquals("burnNCR1632MissingBankSparkler", smokeReader.pipeError); + Assertions.assertEquals("burnNCR1632MissingSparkler", smokeReader.pipeError); cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); // the print above auto value + next test cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // normal NXX_123 @@ -69,7 +69,7 @@ public class StenoLexerNCRTest { cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 123); // normal NXX_123 smokeReader.reset(); lexer.read(cdc); - String res = "[0:1:burnNCR1632MissingBankSparkler][0:8:burnNCR1632MissingBankSparkler]¹³⁷⁴³⁸⁹⁵³⁵⁹⁴/₁₃₄₂₁₇₇₃₉[0:16:burnNCR1632MissingBankSparkler]"; + String res = "[0:1:burnNCR1632MissingSparkler][0:8:burnNCR1632MissingSparkler]¹³⁷⁴³⁸⁹⁵³⁵⁹⁴/₁₃₄₂₁₇₇₃₉[0:16:burnNCR1632MissingSparkler]"; Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } @@ -108,8 +108,8 @@ public class StenoLexerNCRTest { for (int i = FourCornerDotCake.FC_NCR1632_DEN.getStop(); i >= FourCornerDotCake.FC_NCR1632_DEN.getStart(); i = i - 512) { cdc.add(i); } - String resSuper = "²⁴⁷³³⁰⁴⁰¹⁴⁷³¹⁰⁴⁵³⁴⁰⁶⁰⁵⁰²⁵²¹⁰¹⁹⁶⁴⁷¹⁹⁰⁰³⁵¹³¹³⁴⁹¹⁰¹²¹¹⁸³⁹⁹¹⁴⁰⁶³⁰⁵⁶⁰⁹²⁸⁹⁷²²⁵¹⁰⁶⁵³¹⁸⁶⁷¹⁷⁰³¹⁶⁴⁰¹⁰⁶¹²⁴³⁰⁴⁴⁹⁸⁹⁵⁹⁷⁶⁷¹⁴²⁶⁰¹⁶¹³⁹³³⁹³⁵¹³⁶⁵⁰³⁴³⁰⁶⁷⁵¹²⁰⁹⁹⁶⁷⁵⁴⁶¹⁵⁵¹⁰¹⁸⁹³¹⁶⁷⁹¹⁶⁶⁰⁶⁷⁷²¹⁴⁸⁶⁹⁹¹³⁵"; - String resSuber = "₂₄₇₃₃₀₄₀₁₄₇₃₁₀₄₅₃₄₀₆₀₅₀₂₅₂₁₀₁₉₆₄₇₁₉₀₀₃₅₁₃₁₃₄₉₁₀₁₂₁₁₈₃₉₉₁₄₀₆₃₀₅₆₀₉₂₈₉₇₂₂₅₁₀₆₅₃₁₈₆₇₁₇₀₃₁₆₄₀₁₀₆₁₂₄₃₀₄₄₉₈₉₅₉₇₆₇₁₄₂₆₀₁₆₁₃₉₃₃₉₃₅₁₃₆₅₀₃₄₃₀₆₇₅₁₂₀₉₉₆₇₅₄₆₁₅₅₁₀₁₈₉₃₁₆₇₉₁₆₆₀₆₇₇₂₁₄₈₆₉₉₁₃₅"; + String resSuper = "⁻¹⁹³²²⁶⁸⁷⁶¹⁵⁰⁸⁶²⁹¹⁷²³⁴⁷⁶⁷⁵⁹⁴⁵⁴⁶⁵⁹⁹³⁶⁷²¹⁴⁹⁴⁶³⁶⁶⁴⁸⁵³²¹⁷⁴⁹⁹³²⁸⁶¹⁷⁶²⁵⁷²⁵⁷⁵⁹⁵⁷¹¹⁴⁴⁷⁸⁰²¹²²⁶⁸⁰⁹⁶⁸⁸³²⁹⁰⁹⁶¹²⁸⁸⁹⁸¹²³¹⁸⁰⁸⁰¹⁵⁷⁵¹⁰⁸⁸⁵⁸⁸⁶⁸²⁵³⁹³³⁰⁵²¹⁴⁹³⁸²⁷⁸⁷¹⁴⁵⁴³³⁶⁷³³⁵⁴⁰³⁷⁴³⁴⁸⁴⁹⁰⁴⁰⁷⁴¹¹⁷¹¹"; + String resSuber = "₋₁₉₃₂₂₆₈₇₆₁₅₀₈₆₂₉₁₇₂₃₄₇₆₇₅₉₄₅₄₆₅₉₉₃₆₇₂₁₄₉₄₆₃₆₆₄₈₅₃₂₁₇₄₉₉₃₂₈₆₁₇₆₂₅₇₂₅₇₅₉₅₇₁₁₄₄₇₈₀₂₁₂₂₆₈₀₉₆₈₈₃₂₉₀₉₆₁₂₈₈₉₈₁₂₃₁₈₀₈₀₁₅₇₅₁₀₈₈₅₈₈₆₈₂₅₃₉₃₃₀₅₂₁₄₉₃₈₂₇₈₇₁₄₅₄₃₃₆₇₃₃₅₄₀₃₇₄₃₄₈₄₉₀₄₀₇₄₁₁₇₁₁"; Assertions.assertEquals(resSuper + "/" + resSuber, FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } }