From 3de5ba556941856c62ddcf6ba0de466b216236c5 Mon Sep 17 00:00:00 2001 From: Willem Date: Fri, 27 Dec 2024 11:08:49 +0100 Subject: [PATCH] Created four corner package and prefixed classes --- README.md | 2 +- .../manifest/WarpManifestTheVersion.java | 2 +- .../FCDotCDC1604DashP6.java} | 68 ++++---- .../FCDotDEC1604DashE2.java} | 12 +- .../java/org/x4o/o2o/fc18/package-info.java | 30 ++++ .../x4o/o2o/io/sax4/X4ContentFrameTag.java | 26 +-- .../java/org/x4o/o2o/CDC1604DashP6Test.java | 150 ------------------ .../x4o/o2o/fc18/FCDotCDC1604DashP6Test.java | 150 ++++++++++++++++++ 8 files changed, 236 insertions(+), 204 deletions(-) rename nx01-x4o-o2o/src/main/java/org/x4o/o2o/{CDC1604DashP6.java => fc18/FCDotCDC1604DashP6.java} (83%) rename nx01-x4o-o2o/src/main/java/org/x4o/o2o/{CDC1604DashP6DEC.java => fc18/FCDotDEC1604DashE2.java} (92%) create mode 100644 nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/package-info.java delete mode 100644 nx01-x4o-o2o/src/test/java/org/x4o/o2o/CDC1604DashP6Test.java create mode 100644 nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6Test.java diff --git a/README.md b/README.md index d6479b4..032e9d3 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ a smurf village and lego bricks. * Local laser pointers [BãßBȍőnSpiderTest](nx01-jpp-base/src/test/java/ᒢᐩᐩ/ᒃᣔᔆᔆᒃᐤᐤᣕ/ᒄᓫᣔᐪᑋ/ᔆᣖᑊᒄᓫᣗ/BãßBȍőnSpiderTest.java) * Lego stair way [LegoBrickStairWay](nx01-jpp-base/src/main/java/ᒢᐩᐩ/ᒡᒢᑊᒻᒻᓫᔿ/ᣳᣝᐤᣜᣳ/ᒢᓫᑊᐣᑊ/LegoBrickStairWay.java) * LegoᐧBrickᐧTapeᐧReplicatorᐧχ3 [LegoBrickTapeStudio](nx01-jpp-base/src/main/java/ᒢᐩᐩ/ᒡᒢᑊᒻᒻᓫᔿ/ᣳᣝᐤᣜᣳ/ᒢᓫᑊᐣᑊ/LegoBrickTapeStudio.java) -* Enterprise mainframe text [CDC1604DashP6](nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6.java) +* Enterprise mainframe text [FCDotCDC1604DashP6](nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6.java) ## Code of Conduct diff --git a/nx01-warp-manifestor/src/main/java/love/distributedrebirth/nx01/warp/manifestor/manifest/WarpManifestTheVersion.java b/nx01-warp-manifestor/src/main/java/love/distributedrebirth/nx01/warp/manifestor/manifest/WarpManifestTheVersion.java index 4e032b0..9f43a0a 100644 --- a/nx01-warp-manifestor/src/main/java/love/distributedrebirth/nx01/warp/manifestor/manifest/WarpManifestTheVersion.java +++ b/nx01-warp-manifestor/src/main/java/love/distributedrebirth/nx01/warp/manifestor/manifest/WarpManifestTheVersion.java @@ -54,7 +54,7 @@ public enum WarpManifestTheVersion { // TODO: Format: SAX3 binary 8 bit XDBX XML with unicode manifest data // VERSION_5_0 - // TODO: Format: SAX4 binary adult 18 bit XML with manifest in 4C, but tags/attr in CDC1604DashP6 + // TODO: Format: SAX4 binary adult 18 bit XML with manifest in 4C, but tags/attr in FCDotCDC1604DashP6 // VERSION_6_0 // TODO: Format: SAX4 binary adult 18 bit XML with manifest data and XML structure in 4C diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6.java similarity index 83% rename from nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6.java rename to nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6.java index e923597..305a2cf 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6.java @@ -20,7 +20,7 @@ * 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.o2o; +package org.x4o.o2o.fc18; import java.util.ArrayList; import java.util.Iterator; @@ -28,7 +28,7 @@ import java.util.List; import java.util.PrimitiveIterator; /// -/// CDC1604DashP6 has 27 pie slice number systems "Packed" for MATH and BASIC letters in a "Six" bit encoding. +/// "FC.CDC1604-P6" has 27 pie slice number systems "Packed" for MATH and BASIC letters in a "Six" bit encoding. /// /// This is used as the first 64 word numbers of the china four corner method, and acts like ascii glue for adult 18 bit computers. /// @@ -40,7 +40,7 @@ import java.util.PrimitiveIterator; /// @author Willem Cazander /// @version 1.0 Dec 22, 2024 /// -public enum CDC1604DashP6 { +public enum FCDotCDC1604DashP6 { // [__NUL][__PIE][__GLUE][__ESC] [__LINE][__SPACE]?! {[(< }])> // ~+-* ,.:; '"`^ =#$% // |_\/ @ABC DEFG HIJK @@ -131,11 +131,11 @@ public enum CDC1604DashP6 { private final byte codePointLower; private final String aliases; - private CDC1604DashP6(char codePoint) { + private FCDotCDC1604DashP6(char codePoint) { this(codePoint, null); } - private CDC1604DashP6(char codePoint, String aliases) { + private FCDotCDC1604DashP6(char codePoint, String aliases) { this.codePoint = (byte) codePoint; this.codePointLower = (byte) Character.toLowerCase(codePoint); this.aliases = aliases; @@ -149,24 +149,24 @@ public enum CDC1604DashP6 { return codePoint; } - static public List convertFromUnicode(String text) { + static public List convertFromUnicode(String text) { return convertFromUnicode(text, false); } - static public List convertFromUnicode(String text, boolean strict) { + static public List convertFromUnicode(String text, boolean strict) { String textSingleNewLines = text.replaceAll("\r\n", "\n"); PrimitiveIterator.OfInt i = textSingleNewLines.codePoints().iterator(); - List result = new ArrayList<>(text.length()); - CDC1604DashP6[] cdcChars = values(); - CDC1604DashP6 cdcNumberTerminator = null; + List result = new ArrayList<>(text.length()); + FCDotCDC1604DashP6[] cdcChars = values(); + FCDotCDC1604DashP6 cdcNumberTerminator = null; while (i.hasNext()) { int codePoint = i.next(); boolean found = false; if ('\r' == codePoint) { - result.add(CDC1604DashP6.__LINE); + result.add(FCDotCDC1604DashP6.__LINE); continue; } - for (CDC1604DashP6 v : cdcChars) { + for (FCDotCDC1604DashP6 v : cdcChars) { if (v.codePoint == codePoint) { result.add(v); found = true; @@ -174,31 +174,31 @@ public enum CDC1604DashP6 { break; } if ('0' == codePoint) { - if (!CDC1604DashP6.NX01_A.equals(cdcNumberTerminator)) { - result.add(CDC1604DashP6.__PIE); - result.add(CDC1604DashP6.NX01_A); - cdcNumberTerminator = CDC1604DashP6.NX01_A; + if (!FCDotCDC1604DashP6.NX01_A.equals(cdcNumberTerminator)) { + result.add(FCDotCDC1604DashP6.__PIE); + result.add(FCDotCDC1604DashP6.NX01_A); + cdcNumberTerminator = FCDotCDC1604DashP6.NX01_A; } - result.add(CDC1604DashP6.NX01_A); + result.add(FCDotCDC1604DashP6.NX01_A); found = true; break; } if (codePoint >= '1' && codePoint <= '9') { - if (!CDC1604DashP6.NX09_I.equals(cdcNumberTerminator)) { - result.add(CDC1604DashP6.__PIE); - result.add(CDC1604DashP6.NX09_I); - cdcNumberTerminator = CDC1604DashP6.NX09_I; + if (!FCDotCDC1604DashP6.NX09_I.equals(cdcNumberTerminator)) { + result.add(FCDotCDC1604DashP6.__PIE); + result.add(FCDotCDC1604DashP6.NX09_I); + cdcNumberTerminator = FCDotCDC1604DashP6.NX09_I; } int cdcNumberOff = codePoint - '1'; // 0 = 1 - int cdcNumber = CDC1604DashP6.NX01_A.ordinal() + cdcNumberOff; - result.add(CDC1604DashP6.values()[cdcNumber]); + int cdcNumber = FCDotCDC1604DashP6.NX01_A.ordinal() + cdcNumberOff; + result.add(FCDotCDC1604DashP6.values()[cdcNumber]); found = true; break; } } if (!found && !strict) { String codePointStr = Character.toString(codePoint); - for (CDC1604DashP6 v : cdcChars) { + for (FCDotCDC1604DashP6 v : cdcChars) { if (v.codePointLower == codePoint) { result.add(v); found = true; @@ -223,38 +223,38 @@ public enum CDC1604DashP6 { return result; } - static public String convertToUnicode(List cdcChars) { + static public String convertToUnicode(List cdcChars) { StringBuilder buf = new StringBuilder(); - Iterator cdc = cdcChars.iterator(); - CDC1604DashP6 numberMode = null; + Iterator cdc = cdcChars.iterator(); + FCDotCDC1604DashP6 numberMode = null; while (cdc.hasNext()) { - CDC1604DashP6 cdcPoint = cdc.next(); + FCDotCDC1604DashP6 cdcPoint = cdc.next(); if (numberMode != null && (cdcPoint.ordinal() > numberMode.ordinal())) { numberMode = null; // out of range } - if (numberMode != null && (cdcPoint.ordinal() < CDC1604DashP6.NX01_A.ordinal())) { + if (numberMode != null && (cdcPoint.ordinal() < FCDotCDC1604DashP6.NX01_A.ordinal())) { numberMode = null; // below index 1 is end number mode } - if (CDC1604DashP6.__PIE.equals(cdcPoint)) { + if (FCDotCDC1604DashP6.__PIE.equals(cdcPoint)) { if (!cdc.hasNext()) { break; } numberMode = cdc.next(); - if (numberMode.ordinal() < CDC1604DashP6.NX01_A.ordinal()) { + if (numberMode.ordinal() < FCDotCDC1604DashP6.NX01_A.ordinal()) { cdcPoint = numberMode; // print char numberMode = null; // illegal number mode } else { continue; } } - if (CDC1604DashP6.__GLUE.equals(cdcPoint)) { + if (FCDotCDC1604DashP6.__GLUE.equals(cdcPoint)) { continue; } if (numberMode == null) { buf.appendCodePoint(cdcPoint.asciiByte()); } else { - int terminatorNum = numberMode.ordinal() - CDC1604DashP6.NX01_A.ordinal() + 1; - int valueNumber = cdcPoint.ordinal() - CDC1604DashP6.NX01_A.ordinal(); + int terminatorNum = numberMode.ordinal() - FCDotCDC1604DashP6.NX01_A.ordinal() + 1; + int valueNumber = cdcPoint.ordinal() - FCDotCDC1604DashP6.NX01_A.ordinal(); appendTerminatorNumber(buf, terminatorNum, valueNumber); } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6DEC.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotDEC1604DashE2.java similarity index 92% rename from nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6DEC.java rename to nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotDEC1604DashE2.java index 109caf4..89e52ce 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/CDC1604DashP6DEC.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/FCDotDEC1604DashE2.java @@ -20,21 +20,23 @@ * 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.o2o; +package org.x4o.o2o.fc18; /** - * Direct Escaped Control of text terminal with CDC1604DashP6 code points. (TODO: currently empty) + * "FC.DEC1604-E2" Four Corner dot Direct or Escaped Control in grid of 16 by 04 of dashed Escape codes V2. * * This block defines "start" points of different escape sequence data-gram encoding within the 6 bit space. * - * A 6 or 8 bit computer use the CDC1604DashP6.__ESC to use these 64 control codes. + * A 6 or 8 bit computer use the __ESC to use these 64 control codes. * * A 18 or 144 bit computer uses this direct as the second 64 part page. (thus number 64 to 127) * + * NOTE: TODO: Currently still all undefined, until time for see below todos. + * * @author Willem Cazander * @version 1.0 Dec 24, 2024 */ -public enum CDC1604DashP6DEC { +public enum FCDotDEC1604DashE2 { RESERVED___NUL, RESERVED___PIE, RESERVED___GLUE, @@ -129,6 +131,6 @@ public enum CDC1604DashP6DEC { // On 18 bit P6DEC system with takes TAG_ANSI_UPPER+__PIE+NX09_I+NX01_A ; - private CDC1604DashP6DEC() { + private FCDotDEC1604DashE2() { } } diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/package-info.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/package-info.java new file mode 100644 index 0000000..589c5d1 --- /dev/null +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/fc18/package-info.java @@ -0,0 +1,30 @@ +/* + * 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. + */ + +/** + * 18 bit Four Corner enterprise number and text encoding. + * + * + * @since 1.0 + */ +package org.x4o.o2o.fc18; diff --git a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax4/X4ContentFrameTag.java b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax4/X4ContentFrameTag.java index 43997ee..00499ec 100644 --- a/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax4/X4ContentFrameTag.java +++ b/nx01-x4o-o2o/src/main/java/org/x4o/o2o/io/sax4/X4ContentFrameTag.java @@ -24,7 +24,7 @@ package org.x4o.o2o.io.sax4; import java.util.Objects; -import org.x4o.o2o.CDC1604DashP6; +import org.x4o.o2o.fc18.FCDotCDC1604DashP6; import org.x4o.o2o.octal.PrimordialOctalOrangeJuice; import org.x4o.o2o.octal.PrimordialOctalOrangeSexWord; @@ -36,27 +36,27 @@ import org.x4o.o2o.octal.PrimordialOctalOrangeSexWord; */ public enum X4ContentFrameTag { - DOCUMENT_END(CDC1604DashP6.NX27_AMPERSAND), - ELEMENT_END(CDC1604DashP6.NX26_Z), + DOCUMENT_END(FCDotCDC1604DashP6.NX27_AMPERSAND), + ELEMENT_END(FCDotCDC1604DashP6.NX26_Z), - ELEMENT_II(CDC1604DashP6.NX05_E), - ELEMENT_SI(CDC1604DashP6.NX24_X), + ELEMENT_II(FCDotCDC1604DashP6.NX05_E), + ELEMENT_SI(FCDotCDC1604DashP6.NX24_X), - ATTRIBUTE_II(CDC1604DashP6.NX01_A), - ATTRIBUTE_SI(CDC1604DashP6.NX02_B), + ATTRIBUTE_II(FCDotCDC1604DashP6.NX01_A), + ATTRIBUTE_SI(FCDotCDC1604DashP6.NX02_B), - NS_DECL_II(CDC1604DashP6.NX13_M), - NS_SCHEMA_SI(CDC1604DashP6.NX14_N), + NS_DECL_II(FCDotCDC1604DashP6.NX13_M), + NS_SCHEMA_SI(FCDotCDC1604DashP6.NX14_N), - CHARACTERS(CDC1604DashP6.NX20_T), - COMMENT(CDC1604DashP6.NX03_C), + CHARACTERS(FCDotCDC1604DashP6.NX20_T), + COMMENT(FCDotCDC1604DashP6.NX03_C), - STRING_ID(CDC1604DashP6.NX09_I), + STRING_ID(FCDotCDC1604DashP6.NX09_I), ; private final PrimordialOctalOrangeJuice tagNumber; - private X4ContentFrameTag(CDC1604DashP6 tag) { + private X4ContentFrameTag(FCDotCDC1604DashP6 tag) { this(PrimordialOctalOrangeSexWord.valueOfSmurf(tag.ordinal())); } diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/CDC1604DashP6Test.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/CDC1604DashP6Test.java deleted file mode 100644 index 3232a38..0000000 --- a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/CDC1604DashP6Test.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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.o2o; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Tests CDC1604DashP6 encoding. - * - * @author Willem Cazander - * @version 1.0 Dec 23, 2024 - */ -public class CDC1604DashP6Test { - - @Test - public void testValues() throws Exception { - Assertions.assertEquals(64, CDC1604DashP6.values().length); - boolean duplicate = false; - Map global = new HashMap<>(); - for (CDC1604DashP6 v : CDC1604DashP6.values()) { - Assertions.assertNotNull(v); - if (global.containsKey(v.asciiByte())) { - duplicate = true; - break; - } - global.put(v.asciiByte(), v); - } - Assertions.assertTrue(global.size() > 1); - Assertions.assertFalse(duplicate, "Duplicate ascii core value detected"); - } - - @Test - public void testAsciiSimple() throws Exception { - List cdc = CDC1604DashP6.convertFromUnicode("foobar"); - Assertions.assertNotNull(cdc); - Assertions.assertFalse(cdc.isEmpty()); - Assertions.assertEquals(6, cdc.size()); - Assertions.assertEquals(CDC1604DashP6.NX06_F, cdc.get(0)); - Assertions.assertEquals(CDC1604DashP6.NX15_O, cdc.get(1)); - Assertions.assertEquals(CDC1604DashP6.NX15_O, cdc.get(2)); - Assertions.assertEquals(CDC1604DashP6.NX02_B, cdc.get(3)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(4)); - Assertions.assertEquals(CDC1604DashP6.NX18_R, cdc.get(5)); - - String out = CDC1604DashP6.convertToUnicode(cdc); - Assertions.assertEquals("FOOBAR", out); - } - - @Test - public void testNumber012() throws Exception { - List cdc = CDC1604DashP6.convertFromUnicode("01201337"); - Assertions.assertNotNull(cdc); - Assertions.assertFalse(cdc.isEmpty()); - Assertions.assertEquals(16, cdc.size()); - Assertions.assertEquals(CDC1604DashP6.__PIE, cdc.get(0)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(1)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(2)); // 0 - Assertions.assertEquals(CDC1604DashP6.__PIE, cdc.get(3)); - Assertions.assertEquals(CDC1604DashP6.NX09_I, cdc.get(4)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(5)); // 1 - Assertions.assertEquals(CDC1604DashP6.NX02_B, cdc.get(6)); // 2 - Assertions.assertEquals(CDC1604DashP6.__PIE, cdc.get(7)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(8)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(9)); // 0 - Assertions.assertEquals(CDC1604DashP6.__PIE, cdc.get(10)); - Assertions.assertEquals(CDC1604DashP6.NX09_I, cdc.get(11)); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(12)); // 1 - Assertions.assertEquals(CDC1604DashP6.NX03_C, cdc.get(13)); // 3 - Assertions.assertEquals(CDC1604DashP6.NX03_C, cdc.get(14)); // 3 - Assertions.assertEquals(CDC1604DashP6.NX07_G, cdc.get(15)); // 7 - - String out = CDC1604DashP6.convertToUnicode(cdc); - Assertions.assertEquals("01201337", out); - } - - @Test - public void testNumberTerminatorOutOfRange() throws Exception { - List cdc = new ArrayList<>(); - cdc.add(CDC1604DashP6.NX24_X); // = X - cdc.add(CDC1604DashP6.__PIE); - cdc.add(CDC1604DashP6._CARET); // ^ - cdc.add(CDC1604DashP6._PERCENT); // = % - cdc.add(CDC1604DashP6.__PIE); - cdc.add(CDC1604DashP6._AT); - cdc.add(CDC1604DashP6.NX11_K); // = K - - String out = CDC1604DashP6.convertToUnicode(cdc); - Assertions.assertEquals("X^%@K", out); - } - - @Test - public void testNumberPieOutOfRange() throws Exception { - List cdc = new ArrayList<>(); - cdc.add(CDC1604DashP6.__PIE); - cdc.add(CDC1604DashP6.NX01_A); - cdc.add(CDC1604DashP6.NX02_B); // = B - cdc.add(CDC1604DashP6.__PIE); - cdc.add(CDC1604DashP6.NX09_I); - cdc.add(CDC1604DashP6.NX03_C); // = 3 - cdc.add(CDC1604DashP6.NX10_J); // = J - - String out = CDC1604DashP6.convertToUnicode(cdc); - Assertions.assertEquals("B3J", out); - } - - @Test - public void testLineEndings() throws Exception { - List cdc = CDC1604DashP6.convertFromUnicode("A\nB\rC\r\nD\n"); - Assertions.assertNotNull(cdc); - Assertions.assertFalse(cdc.isEmpty()); - Assertions.assertEquals(8, cdc.size()); - Assertions.assertEquals(CDC1604DashP6.NX01_A, cdc.get(0)); - Assertions.assertEquals(CDC1604DashP6.__LINE, cdc.get(1)); - Assertions.assertEquals(CDC1604DashP6.NX02_B, cdc.get(2)); - Assertions.assertEquals(CDC1604DashP6.__LINE, cdc.get(3)); - Assertions.assertEquals(CDC1604DashP6.NX03_C, cdc.get(4)); - Assertions.assertEquals(CDC1604DashP6.__LINE, cdc.get(5)); - Assertions.assertEquals(CDC1604DashP6.NX04_D, cdc.get(6)); - Assertions.assertEquals(CDC1604DashP6.__LINE, cdc.get(7)); - - String out = CDC1604DashP6.convertToUnicode(cdc); - Assertions.assertEquals("A\nB\nC\nD\n", out); - } -} diff --git a/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6Test.java b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6Test.java new file mode 100644 index 0000000..fb7d4c9 --- /dev/null +++ b/nx01-x4o-o2o/src/test/java/org/x4o/o2o/fc18/FCDotCDC1604DashP6Test.java @@ -0,0 +1,150 @@ +/* + * 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.o2o.fc18; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests FCDotCDC1604DashP6 encoding. + * + * @author Willem Cazander + * @version 1.0 Dec 23, 2024 + */ +public class FCDotCDC1604DashP6Test { + + @Test + public void testValues() throws Exception { + Assertions.assertEquals(64, FCDotCDC1604DashP6.values().length); + boolean duplicate = false; + Map global = new HashMap<>(); + for (FCDotCDC1604DashP6 v : FCDotCDC1604DashP6.values()) { + Assertions.assertNotNull(v); + if (global.containsKey(v.asciiByte())) { + duplicate = true; + break; + } + global.put(v.asciiByte(), v); + } + Assertions.assertTrue(global.size() > 1); + Assertions.assertFalse(duplicate, "Duplicate ascii core value detected"); + } + + @Test + public void testAsciiSimple() throws Exception { + List cdc = FCDotCDC1604DashP6.convertFromUnicode("foobar"); + Assertions.assertNotNull(cdc); + Assertions.assertFalse(cdc.isEmpty()); + Assertions.assertEquals(6, cdc.size()); + Assertions.assertEquals(FCDotCDC1604DashP6.NX06_F, cdc.get(0)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX15_O, cdc.get(1)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX15_O, cdc.get(2)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX02_B, cdc.get(3)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(4)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX18_R, cdc.get(5)); + + String out = FCDotCDC1604DashP6.convertToUnicode(cdc); + Assertions.assertEquals("FOOBAR", out); + } + + @Test + public void testNumber012() throws Exception { + List cdc = FCDotCDC1604DashP6.convertFromUnicode("01201337"); + Assertions.assertNotNull(cdc); + Assertions.assertFalse(cdc.isEmpty()); + Assertions.assertEquals(16, cdc.size()); + Assertions.assertEquals(FCDotCDC1604DashP6.__PIE, cdc.get(0)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(1)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(2)); // 0 + Assertions.assertEquals(FCDotCDC1604DashP6.__PIE, cdc.get(3)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX09_I, cdc.get(4)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(5)); // 1 + Assertions.assertEquals(FCDotCDC1604DashP6.NX02_B, cdc.get(6)); // 2 + Assertions.assertEquals(FCDotCDC1604DashP6.__PIE, cdc.get(7)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(8)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(9)); // 0 + Assertions.assertEquals(FCDotCDC1604DashP6.__PIE, cdc.get(10)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX09_I, cdc.get(11)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(12)); // 1 + Assertions.assertEquals(FCDotCDC1604DashP6.NX03_C, cdc.get(13)); // 3 + Assertions.assertEquals(FCDotCDC1604DashP6.NX03_C, cdc.get(14)); // 3 + Assertions.assertEquals(FCDotCDC1604DashP6.NX07_G, cdc.get(15)); // 7 + + String out = FCDotCDC1604DashP6.convertToUnicode(cdc); + Assertions.assertEquals("01201337", out); + } + + @Test + public void testNumberTerminatorOutOfRange() throws Exception { + List cdc = new ArrayList<>(); + cdc.add(FCDotCDC1604DashP6.NX24_X); // = X + cdc.add(FCDotCDC1604DashP6.__PIE); + cdc.add(FCDotCDC1604DashP6._CARET); // ^ + cdc.add(FCDotCDC1604DashP6._PERCENT); // = % + cdc.add(FCDotCDC1604DashP6.__PIE); + cdc.add(FCDotCDC1604DashP6._AT); + cdc.add(FCDotCDC1604DashP6.NX11_K); // = K + + String out = FCDotCDC1604DashP6.convertToUnicode(cdc); + Assertions.assertEquals("X^%@K", out); + } + + @Test + public void testNumberPieOutOfRange() throws Exception { + List cdc = new ArrayList<>(); + cdc.add(FCDotCDC1604DashP6.__PIE); + cdc.add(FCDotCDC1604DashP6.NX01_A); + cdc.add(FCDotCDC1604DashP6.NX02_B); // = B + cdc.add(FCDotCDC1604DashP6.__PIE); + cdc.add(FCDotCDC1604DashP6.NX09_I); + cdc.add(FCDotCDC1604DashP6.NX03_C); // = 3 + cdc.add(FCDotCDC1604DashP6.NX10_J); // = J + + String out = FCDotCDC1604DashP6.convertToUnicode(cdc); + Assertions.assertEquals("B3J", out); + } + + @Test + public void testLineEndings() throws Exception { + List cdc = FCDotCDC1604DashP6.convertFromUnicode("A\nB\rC\r\nD\n"); + Assertions.assertNotNull(cdc); + Assertions.assertFalse(cdc.isEmpty()); + Assertions.assertEquals(8, cdc.size()); + Assertions.assertEquals(FCDotCDC1604DashP6.NX01_A, cdc.get(0)); + Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(1)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX02_B, cdc.get(2)); + Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(3)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX03_C, cdc.get(4)); + Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(5)); + Assertions.assertEquals(FCDotCDC1604DashP6.NX04_D, cdc.get(6)); + Assertions.assertEquals(FCDotCDC1604DashP6.__LINE, cdc.get(7)); + + String out = FCDotCDC1604DashP6.convertToUnicode(cdc); + Assertions.assertEquals("A\nB\nC\nD\n", out); + } +}