Added test for importing white space into white space
This commit is contained in:
parent
7aec371c22
commit
a91383f9c4
|
@ -36,7 +36,6 @@ import org.x4o.fc18.cake2.FourCornerX18CakePointSequence;
|
||||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotCMD5401Dash2D;
|
import org.x4o.fc18.cake2.zero33.dec1.FCDotCMD5401Dash2D;
|
||||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotINC0801DashP8;
|
|
||||||
|
|
||||||
/// Imports unicode as four corner BASIC text from the "FC.CDC1604-P6" code page.
|
/// Imports unicode as four corner BASIC text from the "FC.CDC1604-P6" code page.
|
||||||
///
|
///
|
||||||
|
@ -149,20 +148,16 @@ public class FourCornerUnicodeImport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleDataGramWordSpacerTypes(ImportState ctx) {
|
private boolean handleDataGramWordSpacerTypes(ImportState ctx) {
|
||||||
if (' ' == ctx.codePoint) {
|
if (convertWhitespaces) {
|
||||||
ctx.reset();
|
if (!WHITE_SPACES.contains(ctx.codePoint)) {
|
||||||
ctx.output.add(FCDotCMD5401Dash2D.CMD_F4TXT0001_SP);
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
} else if (' ' != ctx.codePoint) {
|
||||||
if (convertWhitespaces == false) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (WHITE_SPACES.contains(ctx.codePoint)) {
|
ctx.reset();
|
||||||
ctx.reset();
|
ctx.output.add(FCDotCMD5401Dash2D.CMD_F4TXT0001_SP);
|
||||||
ctx.output.add(FCDotCMD5401Dash2D.CMD_F4TXT0001_SP);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTypeWriterNewLine(ImportState ctx) {
|
private void sendTypeWriterNewLine(ImportState ctx) {
|
||||||
|
|
|
@ -256,4 +256,24 @@ public class FourCornerUnicodeImportTest {
|
||||||
String out = FourCornerUnicodeDisplay.text().renderFromX06(cdc);
|
String out = FourCornerUnicodeDisplay.text().renderFromX06(cdc);
|
||||||
Assertions.assertEquals("A\nB\nC\nD\nE\nF\n\n\n", out);
|
Assertions.assertEquals("A\nB\nC\nD\nE\nF\n\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhiteSpace() throws Exception {
|
||||||
|
String space16 = "\u3000\u205F\u202F\u200A\u2009\u2008\u2007\u2006\u2005\u2004\u2003\u2002\u2001\u2000\u00A0\u0020";
|
||||||
|
List<FourCornerX06BaklavaPointSequence> cdc = FourCornerUnicodeImport.lossy().convertToX06(space16);
|
||||||
|
Iterator<FourCornerX06BaklavaPointSequence> cdi = cdc.iterator();
|
||||||
|
Assertions.assertNotNull(cdc);
|
||||||
|
Assertions.assertTrue(cdi.hasNext());
|
||||||
|
Assertions.assertFalse(cdc.isEmpty());
|
||||||
|
Assertions.assertEquals(16, cdc.size());
|
||||||
|
while (cdi.hasNext()) {
|
||||||
|
Assertions.assertEquals(FCDotCMD5401Dash2D.CMD_F4TXT0001_SP, cdi.next());
|
||||||
|
}
|
||||||
|
String out = FourCornerUnicodeDisplay.text().renderFromX06(cdc);
|
||||||
|
Assertions.assertEquals(" ", out);
|
||||||
|
|
||||||
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
FourCornerUnicodeImport.strict().convertToX06(space16);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue