FC18: Fixed lexer missing error if first char and add NCR encoding
This commit is contained in:
parent
144d331f88
commit
6b8d281e40
6 changed files with 164 additions and 20 deletions
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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.zero33.FCDotCDC1604DashP6;
|
||||
|
||||
/**
|
||||
* Tests four corner lexer invalid chars.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 4, 2025
|
||||
*/
|
||||
public class LexerInvalidTest {
|
||||
|
||||
@Test
|
||||
public void testInvalid18Plus() throws Exception {
|
||||
String res = "[0:0:burnLexerReservedCakePoint:0x40000]";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(List.of(0x040000)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalid18PlusError() throws Exception {
|
||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||
new FourCornerUnicodeDisplay(true, true, null).renderFromInt18(List.of(0x040000));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidFirstLast() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(0x0400FF);
|
||||
cdc.add(FCDotCDC1604DashP6.NX23_W.ordinal());
|
||||
cdc.add(0x0400FE);
|
||||
cdc.add(FCDotCDC1604DashP6.NX23_W.ordinal());
|
||||
cdc.add(0x0400FD);
|
||||
cdc.add(FCDotCDC1604DashP6.NX23_W.ordinal());
|
||||
cdc.add(0x0400FC);
|
||||
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
|
||||
Assertions.assertTrue(res.contains("400ff"), "No 400ff in: " + res);
|
||||
Assertions.assertTrue(res.contains("400fe"), "No 400fe in: " + res);
|
||||
Assertions.assertTrue(res.contains("400fd"), "No 400fd in: " + res);
|
||||
Assertions.assertTrue(res.contains("400fc"), "No 400fc in: " + res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidGap8() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(0xFF);
|
||||
cdc.add(FCDotCDC1604DashP6.NX01_A.ordinal());
|
||||
cdc.add(0xFE);
|
||||
cdc.add(FCDotCDC1604DashP6.NY01_AT.ordinal());
|
||||
cdc.add(0xFD);
|
||||
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
|
||||
Assertions.assertTrue(res.contains("0xff"), "No 0xff in: " + res);
|
||||
Assertions.assertTrue(res.contains("0xfe"), "No 0xfe in: " + res);
|
||||
Assertions.assertTrue(res.contains("0xfd"), "No 0xfd in: " + res);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,12 +22,14 @@
|
|||
*/
|
||||
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.FourCornerUnicodeMapper;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
|
|
@ -121,10 +123,31 @@ public class LexerNCRTest {
|
|||
@Test
|
||||
public void testNCRLargestF576() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||
|
||||
String res = "¹²³/₄₈₃₀₆₇₁₉₀₃₇₇₁₅₇₂₉₃₀₈₆₉₁₈₉₈₆₃₆₆₄₉₈₄₁₈₀₃₇₃₆₅₉₁₆₂₁₃₃₀₄₃₇₄₈₃₂₁₅₄₄₀₆₄₃₁₄₃₉₈₉₂₇₈₆₁₉₅₀₅₃₀₆₇₀₂₄₂₂₀₈₂₂₇₄₀₃₂₂₂₄₅₃₀₇₉₅₂₀₀₃₉₃₇₇₇₂₁₄₇₁₇₀₆₃₄₈₃₂₆₃₀₃₇₃₄₅₆₉₆₇₈₆₃₅₈₄₁₈₃₃₈₅₀₉₃₅₈₇₁₂₂₆₀₁₈₅₂₉₂₉";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
for (int i = FourCornerDotCake.FC_NCR1632_XD.getStop(); i >= FourCornerDotCake.FC_NCR1632_XD.getStart(); i = i - 512) {
|
||||
cdc.add(i);
|
||||
}
|
||||
for (int i = FourCornerDotCake.FC_NCR1632_XN.getStop(); i >= FourCornerDotCake.FC_NCR1632_XN.getStart(); i = i - 512) {
|
||||
cdc.add(i);
|
||||
}
|
||||
String resSuper = "²⁴⁷³³⁰⁴⁰¹⁴⁷³¹⁰⁴⁵³⁴⁰⁶⁰⁵⁰²⁵²¹⁰¹⁹⁶⁴⁷¹⁹⁰⁰³⁵¹³¹³⁴⁹¹⁰¹²¹¹⁸³⁹⁹¹⁴⁰⁶³⁰⁵⁶⁰⁹²⁸⁹⁷²²⁵¹⁰⁶⁵³¹⁸⁶⁷¹⁷⁰³¹⁶⁴⁰¹⁰⁶¹²⁴³⁰⁴⁴⁹⁸⁹⁵⁹⁷⁶⁷¹⁴²⁶⁰¹⁶¹³⁹³³⁹³⁵¹³⁶⁵⁰³⁴³⁰⁶⁷⁵¹²⁰⁹⁹⁶⁷⁵⁴⁶¹⁵⁵¹⁰¹⁸⁹³¹⁶⁷⁹¹⁶⁶⁰⁶⁷⁷²¹⁴⁸⁶⁹⁹¹³⁶";
|
||||
String resSuber = "₂₄₇₃₃₀₄₀₁₄₇₃₁₀₄₅₃₄₀₆₀₅₀₂₅₂₁₀₁₉₆₄₇₁₉₀₀₃₅₁₃₁₃₄₉₁₀₁₂₁₁₈₃₉₉₁₄₀₆₃₀₅₆₀₉₂₈₉₇₂₂₅₁₀₆₅₃₁₈₆₇₁₇₀₃₁₆₄₀₁₀₆₁₂₄₃₀₄₄₉₈₉₅₉₇₆₇₁₄₂₆₀₁₆₁₃₉₃₃₉₃₅₁₃₆₅₀₃₄₃₀₆₇₅₁₂₀₉₉₆₇₅₄₆₁₅₅₁₀₁₈₉₃₁₆₇₉₁₆₆₀₆₇₇₂₁₄₈₆₉₉₁₃₆";
|
||||
Assertions.assertEquals(resSuper + "/" + resSuber, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRCount1024() throws Exception {
|
||||
List<Integer> cdc = new ArrayList<>();
|
||||
for (int x = 1; x <= 1024; x++) {
|
||||
BigInteger v = BigInteger.valueOf(x);
|
||||
cdc.addAll(FourCornerUnicodeMapper.DICTIONARY.embedNCR1632Denominator(v));
|
||||
|
||||
//cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // NXX_1
|
||||
List<Integer> nomList = FourCornerUnicodeMapper.DICTIONARY.embedNCR1632Numerator(BigInteger.ONE);
|
||||
Assertions.assertEquals(1, nomList.size());
|
||||
cdc.addAll(nomList); // NXX_1
|
||||
}
|
||||
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
|
||||
Assertions.assertTrue(res.startsWith("¹/₁¹/₂"), "missing " + res);
|
||||
Assertions.assertTrue(res.endsWith("¹/₁₀₂₃¹/₁₀₂₄"), "missing " + res);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue