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 234c11d..56699dc 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 @@ -385,19 +385,22 @@ public class FourCornerUnicodeDisplay { } @Override - public void strobeNumberChocoPigFixed(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { + public void strobeNumberChocoPigChoped(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { // TODO: add pure FC6 too like; auto fixedQ = 0QTPF.D2F3432F.A2B43F242E; List numberCandy = new ArrayList<>(); - FourCornerRecipe.toDecimalsX18(numberCandy, 0); - numberCandy.add(FCDotCDC1604DashP6.NX17_Q.ordinal()); - numberCandy.add(FCDotCDC1604DashP6.NX20_T.ordinal()); - if (taste.statusSignPositive()) { - numberCandy.add(FCDotCDC1604DashP6.NX16_P.ordinal()); - } else { - numberCandy.add(FCDotCDC1604DashP6.NX14_N.ordinal()); + //FourCornerRecipe.toDecimalsX18(numberCandy, 0); + //numberCandy.add(FCDotCDC1604DashP6.NX17_Q.ordinal()); + //numberCandy.add(FCDotCDC1604DashP6.NX20_T.ordinal()); + //if (taste.statusSignPositive()) { + // numberCandy.add(FCDotCDC1604DashP6.NX16_P.ordinal()); + //} else { + // numberCandy.add(FCDotCDC1604DashP6.NX14_N.ordinal()); + //} + //numberCandy.add(FCDotCDC1604DashP6.NX01_A.ordinal()); // 10 = decicmals + //numberCandy.add(FCDotCDC1604DashP6.NY16_DOT.ordinal()); + if (taste.statusSignNegative()) { + numberCandy.add(FCDotCDC1604DashP6.NY19_MINUS.ordinal()); // TODO: use name word symbols } - numberCandy.add(FCDotCDC1604DashP6.NX01_A.ordinal()); // 10 = decicmals - numberCandy.add(FCDotCDC1604DashP6.NY16_DOT.ordinal()); FourCornerRecipe.toDecimalsX18(numberCandy, quake); numberCandy.add(FCDotCDC1604DashP6.NY16_DOT.ordinal()); FourCornerRecipe.toDecimalsX18(numberCandy, fraction); diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotCake.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotCake.java index 918ffea..107c209 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotCake.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotCake.java @@ -436,8 +436,8 @@ public enum FourCornerDotCake { FC_DECIMAL2304_BANK(0x03CA38, 4096, "Number choco pig 2304 bit decimal point bank"), FC_FLOAT2304_SEL0(0x03DA38, 192, "Number choco pig 2304 bit floating point select"), FC_FLOAT2304_BANK(0x03DAF8, 4096, "Number choco pig 2304 bit floating point bank"), - FC_FIXED2304_SEL0(0x03EAF8, 192, "Number choco pig 2304 bit fixed point select"), - FC_FIXED2304_BANK(0x03EBB8, 4096, "Number choco pig 2304 bit fixed point bank"), + FC_CHOPED2304_SEL0(0x03EAF8, 192, "Number choco pig 2304 bit choped point select"), + FC_CHOPED2304_BANK(0x03EBB8, 4096, "Number choco pig 2304 bit choped point bank"), // =========== Allow adult escape sequences @@ -562,7 +562,7 @@ public enum FourCornerDotCake { if (idx <= FC_SANDWORM_15.ordinal()) { return FourCornerDotCakeTower.TXT_EMBEDS; } - if (idx <= FC_FIXED2304_BANK.ordinal()) { + if (idx <= FC_CHOPED2304_BANK.ordinal()) { return FourCornerDotCakeTower.TXT_NCR; } return FourCornerDotCakeTower.TXT_ESC; 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 2f2730d..4447569 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 @@ -49,7 +49,7 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7Bereshit { void strobeNumberChocoPigFloat(FCFlameNumberTaste taste, boolean bias, BigInteger exponent, BigInteger mantissa); /// Embed fixed point number. (4+1148+1152) - void strobeNumberChocoPigFixed(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction); + void strobeNumberChocoPigChoped(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction); // XDBX18: doom.wad uses (ARM) Q16.16 which is equal to the real (Texas) Q15.16 (because doom map like E2M3 = 6 bit float) //void strobeStructBlockRemark(boolean beginOrEnd, boolean textOrDoc); @@ -75,7 +75,7 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7Bereshit { } @Override - default void strobeNumberChocoPigFixed(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { + default void strobeNumberChocoPigChoped(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { } } } 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 de331d9..9de0991 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 @@ -427,7 +427,7 @@ public class FourCornerZionStenoGrapher { } @Override - public void strobeNumberChocoPigFixed(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { + public void strobeNumberChocoPigChoped(FCFlameNumberTaste taste, BigInteger quake, BigInteger fraction) { Objects.requireNonNull(quake); Objects.requireNonNull(fraction); requireBigPositive(quake); @@ -435,7 +435,7 @@ public class FourCornerZionStenoGrapher { requireBigPositive(fraction); requireBigMax(fraction, BIG_BITS_1152); BigInteger pig = quake.shiftLeft(1152).add(fraction); - outAddBankCake12(FourCornerDotCake.FC_FIXED2304_SEL0.getStart(), FourCornerDotCake.FC_FIXED2304_BANK.getStart(), NCR_BANK_IDX_TOPPAGE_2304, pig, v -> { + outAddBankCake12(FourCornerDotCake.FC_CHOPED2304_SEL0.getStart(), FourCornerDotCake.FC_CHOPED2304_BANK.getStart(), NCR_BANK_IDX_TOPPAGE_2304, pig, v -> { return (v & 0xFF) + (taste.ordinal() << 8); }); } 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 b75ea80..a40486b 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 @@ -126,6 +126,12 @@ public class FourCornerZionStenoLexer implements FourCornerZionStenoPetroglyphs if (FourCornerDotCake.FC_FLOAT2304_BANK.equals(cakeSlice)) { continue; // parse block manually } + if (FourCornerDotCake.FC_CHOPED2304_SEL0.equals(cakeSlice)) { + continue; // parse block manually + } + if (FourCornerDotCake.FC_CHOPED2304_BANK.equals(cakeSlice)) { + continue; // parse block manually + } if (cakeSlice.name().endsWith("_SEL0") && cakeSlice.name().startsWith("FC_BA")) { continue; // done by bank slices below } @@ -159,7 +165,7 @@ public class FourCornerZionStenoLexer implements FourCornerZionStenoPetroglyphs CAKE_SLICE_EATERS.add(new StenoScannerNumberChocoRational()); CAKE_SLICE_EATERS.add(new StenoScannerNumberChocoDecimal()); CAKE_SLICE_EATERS.add(new StenoScannerNumberChocoFloat()); - CAKE_SLICE_EATERS.add(new StenoScannerNumberChocoFixed()); + CAKE_SLICE_EATERS.add(new StenoScannerNumberChocoChoped()); ArrayList.class.cast(CAKE_SLICE_EATERS).trimToSize(); } @@ -583,10 +589,10 @@ public class FourCornerZionStenoLexer implements FourCornerZionStenoPetroglyphs } } - static final class StenoScannerNumberChocoFixed extends StenoScannerNumberBank { + static final class StenoScannerNumberChocoChoped extends StenoScannerNumberBank { - public StenoScannerNumberChocoFixed() { - super(FourCornerDotCake.FC_FIXED2304_SEL0, FourCornerDotCake.FC_FIXED2304_BANK, NCR_BANK12_SIZE, FCFlameNumberSparklerSmoke.CHOCO_FIXED); + public StenoScannerNumberChocoChoped() { + super(FourCornerDotCake.FC_CHOPED2304_SEL0, FourCornerDotCake.FC_CHOPED2304_BANK, NCR_BANK12_SIZE, FCFlameNumberSparklerSmoke.CHOCO_FIXED); } @Override @@ -595,7 +601,7 @@ public class FourCornerZionStenoLexer implements FourCornerZionStenoPetroglyphs BigInteger pig = lexer.numberBankReadBig12(numberBankTop); BigInteger quake = pig.shiftRight(1152); BigInteger fraction = pig.and(BIG_BITS_1152); - lexer.handler.strobeNumberChocoPigFixed(taste, quake, fraction); + lexer.handler.strobeNumberChocoPigChoped(taste, quake, fraction); } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmokeTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmokeTest.java new file mode 100644 index 0000000..89013c9 --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerSmokeTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.x4o.fc18.zion7; + +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.cake2.FourCornerDotCake; +import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; + +/** + * Tests four corner lexer parts. + * + * @author Willem Cazander + * @version 1.0 Jan 14, 2025 + */ +public class FourCornerZionStenoLexerSmokeTest { + + @Test + public void testNCRSmokeSignals() throws Exception { + TestSmokeReader smokeReader = new TestSmokeReader(); + FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true); + lexer.withSmokeSignals(smokeReader); + + List cdc = new ArrayList<>(); + cdc.add(192 + FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 1); + Assertions.assertEquals(0, smokeReader.pipeSmokeClouds); + lexer.read(cdc); + Assertions.assertEquals(1, smokeReader.pipeSmokeClouds); + Assertions.assertEquals("burnNumberMissingSparkler:CHOCO_RATIONAL", smokeReader.pipeError); + + cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); + cdc.add(FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 123); + cdc.add(FourCornerDotCake.FC_RATIONAL4608_BANK.getStart() + 123); + cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); + + smokeReader.reset(); + lexer.read(cdc); + Assertions.assertEquals(2, smokeReader.pipeSmokeClouds); + + cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.cakePointSequence()); + cdc.add(192 + FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 11); + cdc.add(FourCornerDotCake.FC_RATIONAL4608_BANK.getStart()); + smokeReader.reset(); + lexer.read(cdc); + String res = "[0:1:burnNumberMissingSparkler:CHOCO_RATIONAL][0:8:burnNumberMissingSparkler:CHOCO_RATIONAL][0:16:burnNumberMissingSparkler:CHOCO_RATIONAL]"; + Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(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 364ccbf..4931f36 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,13 +35,8 @@ 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; -import org.x4o.fc18.zion7.flame4.FCFlameFremanChocoBase8; -import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase2; -import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase8; -import org.x4o.fc18.zion7.flame4.FCFlameFremanSignedBase2; import org.x4o.fc18.zion7.flame4.FCFlameNumberTaste; /** @@ -68,107 +63,6 @@ public class StenoGrapherTest { Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res); } - @Test - public void testBASE2Values() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE2Lego(FCFlameFremanLegoBase2.LEGO_0032, BigInteger.valueOf(123)); - writerX18.strobeTheWord(FCDotCDC1604DashP6.NY09_EQUALS.ordinal()); - writerX18.strobeNumberBASE2Int(FCFlameFremanSignedBase2.SIGNED_0128, true, BigInteger.valueOf(123)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("123=-123", resX18); - } - - @Test - public void testBASE8Lego123() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE8Lego(FCFlameFremanLegoBase8.LEGO_0144, BigInteger.valueOf(123)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("123", resX18); - } - - @Test - public void testBASE8Lego123456() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE8Lego(FCFlameFremanLegoBase8.LEGO_0144, BigInteger.valueOf(123456)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("123456", resX18); - } - - @Test - public void testBASE8Choco123() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_POSITIVE, new BigInteger("123", 10)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("123", resX18); - } - - @Test - public void testBASE8Choco123456Neg() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_NEGATIVE, new BigInteger("123456", 10)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("-123456", resX18); - } - - @Test - public void testBASE8ChocoLarge() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_POSITIVE, new BigInteger("1393796574908163946345982392040522594123775", 10)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("1393796574908163946345982392040522594123775", resX18); - } - - @Test - public void testBankDecimalValues() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberChocoPigDecimal(FCFlameNumberTaste.NUMBER_POSITIVE, false, BigInteger.valueOf(123), BigInteger.valueOf(456)); - Assertions.assertEquals(4, outX18.size()); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("(-1)⁰*10¹²³*456", resX18); - } - - @Test - public void testBankDecimalValuesMax() throws Exception { - Assertions.assertEquals(283, FourCornerZionStenoPetroglyphs.BIG_BITS_283.toString(2).length()); - Assertions.assertEquals(2016, FourCornerZionStenoPetroglyphs.BIG_BITS_2016.toString(2).length()); - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberChocoPigDecimal(FCFlameNumberTaste.NUMBER_POSITIVE, false, FourCornerZionStenoPetroglyphs.BIG_BITS_283, FourCornerZionStenoPetroglyphs.BIG_BITS_2016); - Assertions.assertEquals(193, outX18.size()); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("(-1)⁰*10¹⁵⁵⁴¹³⁵¹¹³⁷⁸⁰⁵⁸³²⁵⁶⁷³⁵⁵⁶⁹⁵²⁵⁴⁵⁸⁸¹⁵¹²⁵³¹³⁹²⁵⁴⁷¹²⁴¹⁷¹¹⁶¹⁷⁰⁰¹⁴⁴⁹⁹²⁷⁷⁹¹¹²³⁴²⁸¹⁶⁴¹⁶⁶⁷⁹⁸⁵⁴⁰⁷*7524389324549354450012295667238056650488661292408472865850279440061341770661038088891003609523855490537527473858068236032063038821912119420032983735773778315780422968627185582125139830259059580693966159220800634538007951025529707819651368618588002973837229854435730968342995245834129352264002058451047722604571453619205472623157541916371455764131661512732115122042085430429090324954236930736866452001076451671762299658372499364800367306988138217572983729940207496105489713305332746758395131148149101871456611571055068153665866066783899124296271513772531723497342815490725823828326183977758546404902789185535", resX18); - } - - @Test - public void testBankFloatValues() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - writerX18.strobeNumberChocoPigFloat(FCFlameNumberTaste.NUMBER_NEGATIVE, false, BigInteger.valueOf(456), BigInteger.valueOf(123)); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("(-1)¹*2⁴⁵⁶*1.123", resX18); - } - - @Test - public void testBankRationalValues() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - BigInteger v1 = BigInteger.valueOf(123); - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v1); - BigInteger v2 = BigInteger.valueOf(12345); - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v2); - BigInteger v3 = BigInteger.valueOf(5432); - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_NEGATIVE, v3, FCFlameNumberTaste.NUMBER_NEGATIVE, v3); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅⁻⁵⁴³²/₋₅₄₃₂", resX18); - } - //Test TODO: MOVE + fix java.io.IOException: Expected 9 bytes, got: 3 from PrimordialOctalOrangeString.ioSmurfReadStreamX8 public void testNCRWriteFile() throws Exception { File testFile = new File("target/test-ncr.dat"); @@ -197,32 +91,4 @@ public class StenoGrapherTest { } //testFile.delete(); } - - @Test - public void testBankRationalCount1024() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - for (int x = 1; x <= 1025; x++) { - BigInteger v = BigInteger.valueOf(x); - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v); - } - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertTrue(resX18.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX18); - Assertions.assertTrue(resX18.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX18); - Assertions.assertTrue(resX18.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX18); - } - - @Test - public void testBankRationalValuesMax() throws Exception { - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - BigInteger maxValue = FourCornerZionStenoPetroglyphs.BIG_BITS_2300; - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue, FCFlameNumberTaste.NUMBER_POSITIVE, maxValue); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue, FCFlameNumberTaste.NUMBER_POSITIVE, maxValue.add(BigInteger.ONE)); - }); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue.add(BigInteger.ONE), FCFlameNumberTaste.NUMBER_POSITIVE, maxValue); - }); - } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase2Test.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase2Test.java new file mode 100644 index 0000000..8e063c8 --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase2Test.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.octal8.PrimordialOctal; +import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase2; +import org.x4o.fc18.zion7.flame4.FCFlameFremanSignedBase2; + +/** + * Tests four corner number parts. + * + * @author Willem Cazander + * @version 1.0 Aug 24, 2025 + */ +public class StenoNumberBase2Test { + + @Test + public void testBASE2Lego123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE2Lego(FCFlameFremanLegoBase2.LEGO_0032, BigInteger.valueOf(123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("123", resX18); + } + + @Test + public void testBASE2Int123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE2Int(FCFlameFremanSignedBase2.SIGNED_0128, true, BigInteger.valueOf(123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("-123", resX18); + } + + @Test + public void testBASE2LegoMax() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE2Lego(FCFlameFremanLegoBase2.LEGO_0016, BigInteger.valueOf(0xFFFF)); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + writerX18.strobeNumberBASE2Lego(FCFlameFremanLegoBase2.LEGO_0016, BigInteger.valueOf(0xFFFF + 1)); + }); + } + + @Test + public void testBASE2IntMax() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE2Int(FCFlameFremanSignedBase2.SIGNED_0016, false, BigInteger.valueOf(0x7FFF)); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + writerX18.strobeNumberBASE2Int(FCFlameFremanSignedBase2.SIGNED_0016, false, BigInteger.valueOf(0x7FFF + 1)); + }); + } +} diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase8Test.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase8Test.java new file mode 100644 index 0000000..9e3f03f --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberBase8Test.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.zion7.flame4.FCFlameFremanChocoBase8; +import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase8; +import org.x4o.fc18.zion7.flame4.FCFlameNumberTaste; + +/** + * Tests four corner base8 number parts. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2025 + */ +public class StenoNumberBase8Test { + + @Test + public void testBASE8Lego123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE8Lego(FCFlameFremanLegoBase8.LEGO_0144, BigInteger.valueOf(123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("123", resX18); + } + + @Test + public void testBASE8Lego123456() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE8Lego(FCFlameFremanLegoBase8.LEGO_0144, BigInteger.valueOf(123456)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("123456", resX18); + } + + @Test + public void testBASE8Choco123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_POSITIVE, new BigInteger("123", 10)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("123", resX18); + } + + @Test + public void testBASE8Choco123456Neg() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_NEGATIVE, new BigInteger("123456", 10)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("-123456", resX18); + } + + @Test + public void testBASE8ChocoLarge() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberBASE8Choco(FCFlameFremanChocoBase8.CHOCO_0144, FCFlameNumberTaste.NUMBER_POSITIVE, new BigInteger("1393796574908163946345982392040522594123775", 10)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("1393796574908163946345982392040522594123775", resX18); + } +} diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoChopedTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoChopedTest.java new file mode 100644 index 0000000..518c6ef --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoChopedTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.zion7.flame4.FCFlameNumberTaste; + +/** + * Tests four corner choco choped pig parts. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2025 + */ +public class StenoNumberChocoChopedTest { + + @Test + public void testChochChoped123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigChoped(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.valueOf(456), BigInteger.valueOf(123)); + for (Integer c : outX18) { + System.out.println("c = " + Integer.toHexString(c)); + } + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("456.123", resX18); + } + + @Test + public void testChochChopedNeg456() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigChoped(FCFlameNumberTaste.NUMBER_NEGATIVE, BigInteger.valueOf(789), BigInteger.valueOf(123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("-789;123", resX18); + } +} diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoDecimalTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoDecimalTest.java new file mode 100644 index 0000000..6fa33c7 --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoDecimalTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.zion7.flame4.FCFlameNumberTaste; + +/** + * Tests four corner choco decimal parts. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2025 + */ +public class StenoNumberChocoDecimalTest { + + @Test + public void testChocoDecimal456() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigDecimal(FCFlameNumberTaste.NUMBER_POSITIVE, false, BigInteger.valueOf(123), BigInteger.valueOf(456)); + Assertions.assertEquals(4, outX18.size()); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("(-1)⁰*10¹²³*456", resX18); + } + + @Test + public void testChocoDecimalValuesMax() throws Exception { + Assertions.assertEquals(283, FourCornerZionStenoPetroglyphs.BIG_BITS_283.toString(2).length()); + Assertions.assertEquals(2016, FourCornerZionStenoPetroglyphs.BIG_BITS_2016.toString(2).length()); + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigDecimal(FCFlameNumberTaste.NUMBER_POSITIVE, false, FourCornerZionStenoPetroglyphs.BIG_BITS_283, FourCornerZionStenoPetroglyphs.BIG_BITS_2016); + Assertions.assertEquals(193, outX18.size()); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("(-1)⁰*10¹⁵⁵⁴¹³⁵¹¹³⁷⁸⁰⁵⁸³²⁵⁶⁷³⁵⁵⁶⁹⁵²⁵⁴⁵⁸⁸¹⁵¹²⁵³¹³⁹²⁵⁴⁷¹²⁴¹⁷¹¹⁶¹⁷⁰⁰¹⁴⁴⁹⁹²⁷⁷⁹¹¹²³⁴²⁸¹⁶⁴¹⁶⁶⁷⁹⁸⁵⁴⁰⁷*7524389324549354450012295667238056650488661292408472865850279440061341770661038088891003609523855490537527473858068236032063038821912119420032983735773778315780422968627185582125139830259059580693966159220800634538007951025529707819651368618588002973837229854435730968342995245834129352264002058451047722604571453619205472623157541916371455764131661512732115122042085430429090324954236930736866452001076451671762299658372499364800367306988138217572983729940207496105489713305332746758395131148149101871456611571055068153665866066783899124296271513772531723497342815490725823828326183977758546404902789185535", resX18); + } +} diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoFloatTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoFloatTest.java new file mode 100644 index 0000000..cd49527 --- /dev/null +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoFloatTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2004-2014, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.zion7.flame4.FCFlameNumberTaste; + +/** + * Tests four corner choco float parts. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2025 + */ +public class StenoNumberChocoFloatTest { + + @Test + public void testChochFloat123() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigFloat(FCFlameNumberTaste.NUMBER_NEGATIVE, false, BigInteger.valueOf(456), BigInteger.valueOf(123)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("(-1)¹*2⁴⁵⁶*1.123", resX18); + } + + @Test + public void testChochFloatNeg456() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + writerX18.strobeNumberChocoPigFloat(FCFlameNumberTaste.NUMBER_POSITIVE, true, BigInteger.valueOf(456), BigInteger.valueOf(789)); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("(-1)⁰*2⁻⁴⁵⁶*1.789", resX18); + } +} 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/StenoNumberChocoRationalTest.java similarity index 73% rename from nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java rename to nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoNumberChocoRationalTest.java index dcb342b..02b2855 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/StenoNumberChocoRationalTest.java @@ -22,6 +22,7 @@ */ package org.x4o.fc18.zion7; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -30,45 +31,56 @@ import org.junit.jupiter.api.Test; import org.x4o.fc18.FourCornerUnicodeDisplay; import org.x4o.fc18.cake2.FourCornerDotCake; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; -import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; +import org.x4o.fc18.zion7.flame4.FCFlameNumberTaste; /** - * Tests four corner lexer parts. + * Tests four corner choco rational parts. * * @author Willem Cazander - * @version 1.0 Jan 14, 2025 + * @version 1.0 Aug 24, 2025 */ -public class StenoLexerNCRTest { - +public class StenoNumberChocoRationalTest { + @Test - public void testNCRSmokeSignals() throws Exception { - TestSmokeReader smokeReader = new TestSmokeReader(); - FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true); - lexer.withSmokeSignals(smokeReader); - - List cdc = new ArrayList<>(); - cdc.add(192 + FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 1); - Assertions.assertEquals(0, smokeReader.pipeSmokeClouds); - lexer.read(cdc); - Assertions.assertEquals(1, smokeReader.pipeSmokeClouds); - Assertions.assertEquals("burnNumberMissingSparkler:CHOCO_RATIONAL", smokeReader.pipeError); - - cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); - cdc.add(FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 123); - cdc.add(FourCornerDotCake.FC_RATIONAL4608_BANK.getStart() + 123); - cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); - - smokeReader.reset(); - lexer.read(cdc); - Assertions.assertEquals(2, smokeReader.pipeSmokeClouds); - - cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.cakePointSequence()); - cdc.add(192 + FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart() + 11); - cdc.add(FourCornerDotCake.FC_RATIONAL4608_BANK.getStart()); - smokeReader.reset(); - lexer.read(cdc); - String res = "[0:1:burnNumberMissingSparkler:CHOCO_RATIONAL][0:8:burnNumberMissingSparkler:CHOCO_RATIONAL][0:16:burnNumberMissingSparkler:CHOCO_RATIONAL]"; - Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); + public void testChocoRationalValues() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + BigInteger v1 = BigInteger.valueOf(123); + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v1); + BigInteger v2 = BigInteger.valueOf(12345); + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v2); + BigInteger v3 = BigInteger.valueOf(5432); + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_NEGATIVE, v3, FCFlameNumberTaste.NUMBER_NEGATIVE, v3); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅⁻⁵⁴³²/₋₅₄₃₂", resX18); + } + + @Test + public void testChocoRationalCount1024() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + for (int x = 1; x <= 1025; x++) { + BigInteger v = BigInteger.valueOf(x); + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, BigInteger.ONE, FCFlameNumberTaste.NUMBER_POSITIVE, v); + } + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); + Assertions.assertTrue(resX18.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX18); + Assertions.assertTrue(resX18.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX18); + Assertions.assertTrue(resX18.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX18); + } + + @Test + public void testBankRationalValuesMax() throws Exception { + List outX18 = new ArrayList<>(); + FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); + BigInteger maxValue = FourCornerZionStenoPetroglyphs.BIG_BITS_2300; + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue, FCFlameNumberTaste.NUMBER_POSITIVE, maxValue); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue, FCFlameNumberTaste.NUMBER_POSITIVE, maxValue.add(BigInteger.ONE)); + }); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + writerX18.strobeNumberChocoMarriedPigsRational(FCFlameNumberTaste.NUMBER_POSITIVE, maxValue.add(BigInteger.ONE), FCFlameNumberTaste.NUMBER_POSITIVE, maxValue); + }); } @Test @@ -108,7 +120,7 @@ public class StenoLexerNCRTest { } @Test - public void testNCRLargestF576() throws Exception { + public void testNCRLargest() throws Exception { List cdc = new ArrayList<>(); cdc.add(FourCornerDotCake.FC_RATIONAL4608_SEL0.getStop()); for (int i = FourCornerDotCake.FC_RATIONAL4608_SEL0.getStop(); i >= FourCornerDotCake.FC_RATIONAL4608_SEL0.getStart(); i--) {