Added more smoke for NCR and test the big indian smoke reader
This commit is contained in:
parent
b8139ebda0
commit
d96e6e3e6e
|
@ -282,17 +282,20 @@ public class FourCornerZionStenoLexer {
|
||||||
private void handlePoints(List<Integer> slicedPoints) {
|
private void handlePoints(List<Integer> slicedPoints) {
|
||||||
int denominatorBank[] = new int[64]; // <== is the terminator select per 9 bit group
|
int denominatorBank[] = new int[64]; // <== is the terminator select per 9 bit group
|
||||||
int numeratorBank[] = new int[64];
|
int numeratorBank[] = new int[64];
|
||||||
boolean fired = false;
|
boolean errorZeroSparks = true;
|
||||||
|
boolean errorUnusedSparks = true;
|
||||||
for (Integer cakePoint : slicedPoints) {
|
for (Integer cakePoint : slicedPoints) {
|
||||||
if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) {
|
if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) {
|
||||||
int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart();
|
int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart();
|
||||||
denominatorBank[denominatorX / 512] = denominatorX % 512;
|
denominatorBank[denominatorX / 512] = denominatorX % 512;
|
||||||
|
errorUnusedSparks = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart();
|
int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart();
|
||||||
numeratorBank[numeratorX / 512] = numeratorX % 512;
|
numeratorBank[numeratorX / 512] = numeratorX % 512;
|
||||||
|
|
||||||
if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) {
|
if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) {
|
||||||
|
errorUnusedSparks = true;
|
||||||
continue; // Only fire fraction on lowest value select
|
continue; // Only fire fraction on lowest value select
|
||||||
}
|
}
|
||||||
BigInteger denominator = BigInteger.ONE;
|
BigInteger denominator = BigInteger.ONE;
|
||||||
|
@ -304,10 +307,15 @@ public class FourCornerZionStenoLexer {
|
||||||
numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i*9));
|
numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i*9));
|
||||||
}
|
}
|
||||||
handler.strobeNCR1632(denominator, numerator);
|
handler.strobeNCR1632(denominator, numerator);
|
||||||
fired = true;
|
errorZeroSparks = false;
|
||||||
|
errorUnusedSparks = false;
|
||||||
}
|
}
|
||||||
if (fired == false && smokeSignals != null) {
|
if (smokeSignals != null) {
|
||||||
smokeSignals.burnInvalidNCR1632(currLine, currCol);
|
if (errorZeroSparks) {
|
||||||
|
smokeSignals.burnNCR1632ZeroSparks(currLine, currCol);
|
||||||
|
} else if (errorUnusedSparks) {
|
||||||
|
smokeSignals.burnNCR1632UnusedSparks(currLine, currCol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,9 @@ public interface FourCornerZionStenoLexerSmoke {
|
||||||
|
|
||||||
void burnInvalidEscape(int line, int col, int cakePoint);
|
void burnInvalidEscape(int line, int col, int cakePoint);
|
||||||
|
|
||||||
void burnInvalidNCR1632(int line, int col);
|
void burnNCR1632ZeroSparks(int line, int col);
|
||||||
|
|
||||||
|
void burnNCR1632UnusedSparks(int line, int col);
|
||||||
|
|
||||||
interface Adapter extends FourCornerZionStenoLexerSmoke {
|
interface Adapter extends FourCornerZionStenoLexerSmoke {
|
||||||
|
|
||||||
|
@ -57,7 +59,11 @@ public interface FourCornerZionStenoLexerSmoke {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void burnInvalidNCR1632(int line, int col) {
|
default void burnNCR1632ZeroSparks(int line, int col) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void burnNCR1632UnusedSparks(int line, int col) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.o2o.fc18.zion7;
|
package org.x4o.o2o.fc18.zion7;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -30,9 +29,7 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.x4o.o2o.fc18.FourCornerDotCake;
|
import org.x4o.o2o.fc18.FourCornerDotCake;
|
||||||
import org.x4o.o2o.fc18.FourCornerUnicodeDisplay;
|
import org.x4o.o2o.fc18.FourCornerUnicodeDisplay;
|
||||||
import org.x4o.o2o.fc18.FourCornerUnicodeImport;
|
|
||||||
import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints;
|
import org.x4o.o2o.fc18.FourCornerX06BaklavaPoints;
|
||||||
import org.x4o.o2o.fc18.pie9c.FCDotPIE9CDash26;
|
|
||||||
import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6;
|
import org.x4o.o2o.fc18.zero33.FCDotCDC1604DashP6;
|
||||||
import org.x4o.o2o.fc18.zero33.FCDotDEC0127DashPX0;
|
import org.x4o.o2o.fc18.zero33.FCDotDEC0127DashPX0;
|
||||||
|
|
||||||
|
@ -44,22 +41,48 @@ import org.x4o.o2o.fc18.zero33.FCDotDEC0127DashPX0;
|
||||||
*/
|
*/
|
||||||
public class LexerNCRTest {
|
public class LexerNCRTest {
|
||||||
|
|
||||||
int errorLine = -1;
|
SmokeReader SMOKE_READER = new SmokeReader();
|
||||||
|
|
||||||
|
class SmokeReader implements FourCornerZionStenoLexerSmoke.Adapter {
|
||||||
|
|
||||||
|
int errorNCRZeroSparks = -1;
|
||||||
|
int errorNCRUnusedSparks = -1;
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
errorNCRZeroSparks = -1;
|
||||||
|
errorNCRUnusedSparks = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void burnNCR1632ZeroSparks(int line, int col) {
|
||||||
|
errorNCRZeroSparks = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void burnNCR1632UnusedSparks(int line, int col) {
|
||||||
|
errorNCRUnusedSparks = line;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNCRInvalid() throws Exception {
|
public void testNCRInvalid() throws Exception {
|
||||||
|
FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true);
|
||||||
|
lexer.withSmokeSignals(SMOKE_READER);
|
||||||
List<Integer> cdc = new ArrayList<>();
|
List<Integer> cdc = new ArrayList<>();
|
||||||
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 1);
|
||||||
//cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
|
||||||
|
|
||||||
FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true);
|
SMOKE_READER.reset();
|
||||||
lexer.withSmokeSignals(new FourCornerZionStenoLexerSmoke.Adapter() {
|
lexer.read(cdc);
|
||||||
@Override
|
Assertions.assertEquals(-1, SMOKE_READER.errorNCRUnusedSparks);
|
||||||
public void burnInvalidNCR1632(int line, int col) {
|
Assertions.assertEquals(0, SMOKE_READER.errorNCRZeroSparks);
|
||||||
errorLine = line;
|
|
||||||
}
|
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // NXX_123
|
||||||
}).read(cdc);
|
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*63) + 2);
|
||||||
Assertions.assertEquals(0, errorLine);
|
|
||||||
|
SMOKE_READER.reset();
|
||||||
|
lexer.read(cdc);
|
||||||
|
Assertions.assertEquals(0, SMOKE_READER.errorNCRUnusedSparks);
|
||||||
|
Assertions.assertEquals(-1, SMOKE_READER.errorNCRZeroSparks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue