From 3ce37b4a1dd0405657c1633f4c2888d280c96d95 Mon Sep 17 00:00:00 2001 From: Michael Beckerle Date: Thu, 18 Jan 2024 14:30:42 -0500 Subject: [PATCH] Fix zoned EBCDIC overpunched signs Canonical form for a positive overpunched sign of +5 in ebcdic is C5, not F5. So positive overpunched sign numbers that don't have the C0 to C9 will be parsed fine, but unparsed as C0 to C9. Implemented alternate negative overpunched sign chars B0 to B9 also. These are also canonicalized by unparsing to D0 to D9. Added tests at unit and TDML level Compatibility: There is no compatibiliy issue for parse-only applications. This changes the behavior of unparsing for overpunched signs for EBCDIC characters. The prior behavior was incorrect, to the point of being relatively unusable for unparsing, so there is no feature in this PR to provide backward compatibility with the prior behavior. DAFFODIL-2873, DAFFODIL-2874 --- .../grammar/ElementBaseGrammarMixin.scala | 20 +- .../grammar/primitives/PrimitivesZoned.scala | 4 +- .../io/processors/charset/BitsCharset.scala | 20 + .../daffodil/lib/util/DecimalUtils.scala | 96 +- .../daffodil/lib/util/TestDecimalUtils.scala | 1655 ++++++++++++++--- .../runtime1/ConvertZonedNumberUnparser.scala | 4 +- .../processors/parsers/ZonedTextParsers.scala | 4 +- .../daffodil/section13/zoned/zoned2.tdml | 172 ++ .../daffodil/section13/zoned/TestZoned.scala | 24 + 9 files changed, 1710 insertions(+), 289 deletions(-) create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section13/zoned/zoned2.tdml diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala index f28c727d01..f34f1e1bd9 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala @@ -27,13 +27,13 @@ import org.apache.daffodil.core.grammar.primitives.ConvertTextBooleanPrim import org.apache.daffodil.core.grammar.primitives.LeadingSkipRegion import org.apache.daffodil.core.grammar.primitives.LiteralValueNilOfSpecifiedLength import org.apache.daffodil.core.grammar.primitives.SimpleNilOrValue -import org.apache.daffodil.core.grammar.primitives._ // there are too many to show individually +import org.apache.daffodil.core.grammar.primitives._ import org.apache.daffodil.core.runtime1.ElementBaseRuntime1Mixin import org.apache.daffodil.lib.api.WarnID import org.apache.daffodil.lib.exceptions.Assert import org.apache.daffodil.lib.schema.annotation.props.Found import org.apache.daffodil.lib.schema.annotation.props.NotFound -import org.apache.daffodil.lib.schema.annotation.props.gen._ // there are too many to show individually +import org.apache.daffodil.lib.schema.annotation.props.gen._ import org.apache.daffodil.lib.util.PackedSignCodes import org.apache.daffodil.lib.xml.GlobalQName import org.apache.daffodil.lib.xml.XMLUtils @@ -700,6 +700,22 @@ trait ElementBaseGrammarMixin ConvertZonedCombinator(this, stringValue, textZonedConverter) } + /** + * True if the encoding is known to be an EBCDIC one, as in the encoding is not a runtime expression + * and it's some ebcdic flavor. If it's any ascii flavor or a runtime expression this is false. + */ + lazy val isKnownEBCDICEncoding: Boolean = + charsetEv.optConstant.map { _.isEbcdicFamily() }.getOrElse(false) + + /** + * Avoids requesting the textZonedSignStyle property if we know the encoding + * is an EBCDIC flavor. + */ + lazy val optTextZonedSignStyle = { + if (isKnownEBCDICEncoding) None + else Some(textZonedSignStyle) + } + private lazy val textConverter = { primType match { case _: NodeInfo.Numeric.Kind => ConvertTextStandardNumberPrim(this) diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesZoned.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesZoned.scala index 060613858f..772db6b134 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesZoned.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesZoned.scala @@ -201,7 +201,7 @@ case class ConvertZonedNumberPrim(e: ElementBase) new ConvertZonedNumberParser( opl, textNumberFormatEv, - e.textZonedSignStyle, + e.optTextZonedSignStyle, e.elementRuntimeData, textDecimalVirtualPoint, ) @@ -209,7 +209,7 @@ case class ConvertZonedNumberPrim(e: ElementBase) override lazy val unparser: Unparser = new ConvertZonedNumberUnparser( opl, - e.textZonedSignStyle, + e.optTextZonedSignStyle, e.elementRuntimeData, textDecimalVirtualPoint, ) diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/processors/charset/BitsCharset.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/processors/charset/BitsCharset.scala index 674e7f981b..17f9fbcc01 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/processors/charset/BitsCharset.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/processors/charset/BitsCharset.scala @@ -22,6 +22,7 @@ import java.nio.charset.CoderResult import java.nio.charset.CodingErrorAction import java.nio.charset.{ Charset => JavaCharset } import java.nio.charset.{ CharsetEncoder => JavaCharsetEncoder } +import scala.collection.convert.ImplicitConversions.`collection AsScalaIterable` import org.apache.daffodil.lib.exceptions.Assert import org.apache.daffodil.lib.schema.annotation.props.gen.BitOrder @@ -59,6 +60,15 @@ trait BitsCharset extends Serializable { def newDecoder(): BitsCharsetDecoder def newEncoder(): BitsCharsetEncoder + /** + * Used to determine if zoned numbers use ascii or ebcdic conventions + * for overpunched signs. This determines whether the textZonedSignStyle property is needed or not. + * + * Override in any EBCDIC family charset definition. + * @return true if the charset is an EBCDIC family charset. + */ + def isEbcdicFamily(): Boolean = false + def maybeFixedWidth: MaybeInt final def padCharWidthInBits = { @@ -108,6 +118,16 @@ trait BitsCharsetJava extends BitsCharset { else MaybeInt.Nope } + private lazy val hasNameOrAliasContainingEBCDIC = { + val allCharsetNames = (javaCharset.aliases().toSeq :+ name :+ javaCharset.name()).map { + _.toUpperCase + } + val res = allCharsetNames.exists(_.contains("EBCDIC")) + res + } + + override def isEbcdicFamily(): Boolean = hasNameOrAliasContainingEBCDIC + override def newEncoder() = new BitsCharsetWrappingJavaCharsetEncoder(this, javaCharset.newEncoder()) diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/DecimalUtils.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/DecimalUtils.scala index 99a220a00c..ddca6c221a 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/DecimalUtils.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/DecimalUtils.scala @@ -386,6 +386,45 @@ object DecimalUtils { outArray } + /** + * These are the java characters corresponding to EBCDIC B0 to B9. + * These are commonly "^£¥·©§¶¼½¾" but we compute them by decoding to + * avoid literal charset issues. + * + * Note that in Java chars (which are unicode), these do not have adjacent code points. + * They are (hex) 5e, a3, a5, b7, a9, a7, b6, bc, bd, be. + */ + private val B0_to_B9_chars = "^£¥·©§¶¼½¾" + + /** + * Despite the name, this does not actually convert the digit from EBCDIC encoding. + * The characters have already been decoded from whatever charset into Unicode code points. + * What this does is deal with overpunched positive and negative sign character mappings. + * In this case positive are 0-9 and "{ABCDEFGHI", negative are "}JKLMNOPQR" and + * what we call the B0_to_B9 characters, which are "^£¥·©§¶¼½¾". + * @param digit + * @return A pair of the integer the digit represents, and a boolean indicating if negative. + */ + def convertFromZonedEBCDIC(digit: Char): (Int, Boolean) = { + if ((digit >= '0') && (digit <= '9')) // positive 0-9 + (digit - 48, false) + else if (digit == '{') // positive 0 aka hex C0 ebcdic + (0, false) + else if ((digit >= 'A') && (digit <= 'I')) // positive 1-9 as C1 to C9 i.e, "ABCDEFGHI" + (digit - 'A' + 1, false) + else if (digit == '}') // negative 0 aka hex D0 ebcdic + (0, true) + else if ((digit >= 'J') && (digit <= 'R')) // negative 1-9 as hex D1 to D9. + (digit - 'J' + 1, true) + else { + val index = B0_to_B9_chars.indexOf(digit) + if (index >= 0) + (index, true) + else + throw new NumberFormatException("Invalid zoned digit: " + digit) + } + } + def convertFromAsciiStandard(digit: Char): (Int, Boolean) = { if ((digit >= '0') && (digit <= '9')) // positive 0-9 (digit - 48, false) @@ -417,6 +456,25 @@ object DecimalUtils { throw new NumberFormatException("Invalid zoned digit: " + digit) } + /** + * Does not encode to the EBCDIC charset, but converts overpunched sign + * digits to their corresponding Zoned overpunched representation characters. + * Positive 0 to 9 become "{ABCDEFGHI" respectively. Negative 0 to 9 + * become "}JKLMNOPQR" respectively. + * @param digit - the digit, as a char '0' to '9' + * @param positive - true if positive, false if negative + * @return the character needed to represent this character as an overpunched sign digit. + */ + def convertToZonedEBCDIC(digit: Char, positive: Boolean): Char = { + val pos: Int = digit - '0' + if (pos > 9 || pos < 0) + throw new NumberFormatException("Invalid zoned digit: " + digit) + if (positive) + "{ABCDEFGHI".charAt(pos) + else + "}JKLMNOPQR".charAt(pos) + } + def convertToAsciiTranslatedEBCDIC(digit: Char, positive: Boolean): Char = { if (positive) { if (digit == '0') @@ -470,7 +528,7 @@ object DecimalUtils { def zonedToNumber( num: String, - zonedStyle: TextZonedSignStyle, + optZonedStyle: Option[TextZonedSignStyle], opl: OverpunchLocation.Value, ): String = { val opindex = opl match { @@ -483,24 +541,27 @@ object DecimalUtils { if (opl == OverpunchLocation.None) { num } else { - val (digit, opneg) = zonedStyle match { - case TextZonedSignStyle.AsciiStandard => convertFromAsciiStandard(num(opindex)) - case TextZonedSignStyle.AsciiTranslatedEBCDIC => + val (digit, opneg) = optZonedStyle match { + case None => convertFromZonedEBCDIC(num(opindex)) + case Some(TextZonedSignStyle.AsciiStandard) => convertFromAsciiStandard(num(opindex)) + case Some(TextZonedSignStyle.AsciiTranslatedEBCDIC) => convertFromAsciiTranslatedEBCDIC(num(opindex)) - case TextZonedSignStyle.AsciiCARealiaModified => + case Some(TextZonedSignStyle.AsciiCARealiaModified) => convertFromAsciiCARealiaModified(num(opindex)) - case TextZonedSignStyle.AsciiTandemModified => + case Some(TextZonedSignStyle.AsciiTandemModified) => convertFromAsciiTandemModified(num(opindex)) } - val convertedNum = (opneg, opl) match { - case (true, OverpunchLocation.Start) => "-" + digit + num.substring(1) - case (false, OverpunchLocation.Start) => digit + num.substring(1) - case (true, OverpunchLocation.End) => "-" + num.substring(0, opindex) + digit - case (false, OverpunchLocation.End) => num.substring(0, opindex) + digit + val allDigits = opl match { + case OverpunchLocation.Start => digit + num.substring(1) + case OverpunchLocation.End => num.substring(0, opindex) + digit case _ => Assert.impossible() } + val convertedNum = if (opneg) "-" + allDigits else allDigits + // It is still possible for this to be an illegal/malformed number like "-1K3" + // because nothing has yet checked the interior chars are all digits. + // But this will be caught later when the string is converted to a number. convertedNum } } @@ -510,7 +571,7 @@ object DecimalUtils { def zonedFromNumber( num: String, - zonedStyle: TextZonedSignStyle, + optZonedStyle: Option[TextZonedSignStyle], opl: OverpunchLocation.Value, ): String = { val positive = (num.charAt(0) != '-') @@ -529,14 +590,15 @@ object DecimalUtils { if (!positive) Assert.impossible() inStr } else { - val digit = zonedStyle match { - case TextZonedSignStyle.AsciiStandard => + val digit = optZonedStyle match { + case None => convertToZonedEBCDIC(inStr(opindex), positive) + case Some(TextZonedSignStyle.AsciiStandard) => convertToAsciiStandard(inStr(opindex), positive) - case TextZonedSignStyle.AsciiTranslatedEBCDIC => + case Some(TextZonedSignStyle.AsciiTranslatedEBCDIC) => convertToAsciiTranslatedEBCDIC(inStr(opindex), positive) - case TextZonedSignStyle.AsciiCARealiaModified => + case Some(TextZonedSignStyle.AsciiCARealiaModified) => convertToAsciiCARealiaModified(inStr(opindex), positive) - case TextZonedSignStyle.AsciiTandemModified => + case Some(TextZonedSignStyle.AsciiTandemModified) => convertToAsciiTandemModified(inStr(opindex), positive) } diff --git a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestDecimalUtils.scala b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestDecimalUtils.scala index de4a8542a1..b4a402b893 100644 --- a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestDecimalUtils.scala +++ b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestDecimalUtils.scala @@ -1328,101 +1328,111 @@ class TestDecimalUtils { @Test def zonedIntAsciiStandardPos1(): Unit = { val num = "1" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "1") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), num, ) } @Test def zonedIntAsciiStandardPos2(): Unit = { val num = "12" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End) System.out.println("Result: " + result) assertEquals(result, "12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End), num, ) } @Test def zonedIntAsciiStandardPos3(): Unit = { val num = "123" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.None) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.None) assertEquals(result, "123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.None), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.None), num, ) } @Test def zonedIntAsciiStandardPos4(): Unit = { val num = "1234567890" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), num, ) } @Test def zonedIntAsciiStandardPos5(): Unit = { val num = "000000000001234567890" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "000000000001234567890", ) } @Test def zonedIntAsciiStandardNeg1(): Unit = { val num = "q" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "-1") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), num, ) } @Test def zonedIntAsciiStandardNeg2(): Unit = { val num = "1r" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End) assertEquals(result, "-12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End), num, ) } @Test def zonedIntAsciiStandardNeg3(): Unit = { val num = "q23" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "-123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), num, ) } @Test def zonedIntAsciiStandardNeg4(): Unit = { val num = "123456789p" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End) assertEquals(result, "-1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.End), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End), num, ) } @Test def zonedIntAsciiStandardNeg5(): Unit = { val num = "p00000000001234567890" - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "-000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber(result, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), num, ) } @@ -1430,7 +1440,8 @@ class TestDecimalUtils { @Test def zonedIntAsciiStandardInvalidDigit(): Unit = { val num = "z123" try { - val result = zonedToNumber(num, TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start) + val result = + zonedToNumber(num, Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start) assertEquals(result, "-0123") } catch { case nfe: NumberFormatException => @@ -1441,12 +1452,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICPos1(): Unit = { val num = "A" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "1") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiTranslatedEBCDIC, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.Start, ), num, @@ -1456,10 +1471,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICPos2(): Unit = { val num = "1B" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.End) assertEquals(result, "12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), num, ) } @@ -1467,10 +1486,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICPos3(): Unit = { val num = "123" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.None) assertEquals(result, "123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), num, ) } @@ -1478,12 +1501,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICPos4(): Unit = { val num = "A234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "1234567890") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiTranslatedEBCDIC, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.Start, ), num, @@ -1493,10 +1520,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICPos5(): Unit = { val num = "00000000000123456789{" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.End) assertEquals(result, "000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), num, ) } @@ -1504,12 +1535,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICNeg1(): Unit = { val num = "J" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "-1") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiTranslatedEBCDIC, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.Start, ), num, @@ -1519,10 +1554,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICNeg2(): Unit = { val num = "1K" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.End) assertEquals(result, "-12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), num, ) } @@ -1530,12 +1569,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICNeg3(): Unit = { val num = "J23" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "-123") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiTranslatedEBCDIC, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.Start, ), num, @@ -1545,10 +1588,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICNeg4(): Unit = { val num = "123456789}" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.End) assertEquals(result, "-1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), num, ) } @@ -1556,12 +1603,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiTranslatedEBCDICNeg5(): Unit = { val num = "}00000000001234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "-000000000001234567890") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiTranslatedEBCDIC, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), OverpunchLocation.Start, ), num, @@ -1572,7 +1623,11 @@ class TestDecimalUtils { val num = "z123" try { val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ) assertEquals(result, "-0123") } catch { case nfe: NumberFormatException => @@ -1583,12 +1638,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedPos1(): Unit = { val num = "1" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "1") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiCARealiaModified, + Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.Start, ), num, @@ -1598,10 +1657,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedPos2(): Unit = { val num = "12" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.End) assertEquals(result, "12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), num, ) } @@ -1609,10 +1672,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedPos3(): Unit = { val num = "123" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.None) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.None) assertEquals(result, "123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.None), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.None, + ), num, ) } @@ -1620,12 +1687,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedPos4(): Unit = { val num = "1234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "1234567890") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiCARealiaModified, + Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.Start, ), num, @@ -1635,10 +1706,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedPos5(): Unit = { val num = "000000000001234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.End) assertEquals(result, "000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), num, ) } @@ -1646,12 +1721,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedNeg1(): Unit = { val num = "!" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "-1") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiCARealiaModified, + Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.Start, ), num, @@ -1661,10 +1740,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedNeg2(): Unit = { val num = "1\"" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.End) assertEquals(result, "-12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), num, ) } @@ -1672,12 +1755,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedNeg3(): Unit = { val num = "!23" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "-123") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiCARealiaModified, + Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.Start, ), num, @@ -1687,10 +1774,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedNeg4(): Unit = { val num = "123456789 " val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.End) assertEquals(result, "-1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), num, ) } @@ -1698,12 +1789,16 @@ class TestDecimalUtils { @Test def zonedIntAsciiCARealiaModifiedNeg5(): Unit = { val num = " 00000000001234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "-000000000001234567890") assertEquals( zonedFromNumber( result, - TextZonedSignStyle.AsciiCARealiaModified, + Some(TextZonedSignStyle.AsciiCARealiaModified), OverpunchLocation.Start, ), num, @@ -1714,7 +1809,11 @@ class TestDecimalUtils { val num = "z123" try { val result = - zonedToNumber(num, TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ) assertEquals(result, "-0123") } catch { case nfe: NumberFormatException => @@ -1725,10 +1824,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedPos1(): Unit = { val num = "1" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start) assertEquals(result, "1") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), num, ) } @@ -1736,10 +1839,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedPos2(): Unit = { val num = "12" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.End) assertEquals(result, "12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.End, + ), num, ) } @@ -1747,10 +1854,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedPos3(): Unit = { val num = "123" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.None) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.None) assertEquals(result, "123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.None), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.None, + ), num, ) } @@ -1758,10 +1869,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedPos4(): Unit = { val num = "1234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start) assertEquals(result, "1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), num, ) } @@ -1769,10 +1884,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedPos5(): Unit = { val num = "000000000001234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.End) assertEquals(result, "000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.End, + ), num, ) } @@ -1780,10 +1899,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedNeg1(): Unit = { val num = "" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start) assertEquals(result, "-1") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), num, ) } @@ -1791,10 +1914,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedNeg2(): Unit = { val num = "1‚" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.End) assertEquals(result, "-12") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.End, + ), num, ) } @@ -1802,10 +1929,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedNeg3(): Unit = { val num = "23" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start) assertEquals(result, "-123") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), num, ) } @@ -1813,10 +1944,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedNeg4(): Unit = { val num = "123456789€" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.End) assertEquals(result, "-1234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.End, + ), num, ) } @@ -1824,10 +1959,14 @@ class TestDecimalUtils { @Test def zonedIntAsciiTandemModifiedNeg5(): Unit = { val num = "€00000000001234567890" val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber(num, Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start) assertEquals(result, "-000000000001234567890") assertEquals( - zonedFromNumber(result, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + result, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), num, ) } @@ -1836,7 +1975,11 @@ class TestDecimalUtils { val num = "z123" try { val result = - zonedToNumber(num, TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start) + zonedToNumber( + num, + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ) assertEquals(result, "-0123") } catch { case nfe: NumberFormatException => @@ -1846,733 +1989,1717 @@ class TestDecimalUtils { @Test def zonedIntAsciiStandardAllDigits(): Unit = { assertEquals( - zonedToNumber("0", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("0", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "0", ) assertEquals( - zonedFromNumber("0", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("0", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "0", ) assertEquals( - zonedToNumber("1", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("1", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "1", ) assertEquals( - zonedFromNumber("1", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("1", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "1", ) assertEquals( - zonedToNumber("2", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("2", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "2", ) assertEquals( - zonedFromNumber("2", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("2", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "2", ) assertEquals( - zonedToNumber("3", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("3", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "3", ) assertEquals( - zonedFromNumber("3", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("3", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "3", ) assertEquals( - zonedToNumber("4", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("4", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "4", ) assertEquals( - zonedFromNumber("4", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("4", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "4", ) assertEquals( - zonedToNumber("5", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("5", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "5", ) assertEquals( - zonedFromNumber("5", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("5", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "5", ) assertEquals( - zonedToNumber("6", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("6", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "6", ) assertEquals( - zonedFromNumber("6", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("6", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "6", ) assertEquals( - zonedToNumber("7", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("7", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "7", ) assertEquals( - zonedFromNumber("7", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("7", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "7", ) assertEquals( - zonedToNumber("8", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("8", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "8", ) assertEquals( - zonedFromNumber("8", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("8", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "8", ) assertEquals( - zonedToNumber("9", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("9", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "9", ) assertEquals( - zonedFromNumber("9", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("9", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "9", ) assertEquals( - zonedToNumber("1p", TextZonedSignStyle.AsciiStandard, OverpunchLocation.End), + zonedToNumber("1p", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End), "-10", ) assertEquals( - zonedFromNumber("-10", TextZonedSignStyle.AsciiStandard, OverpunchLocation.End), + zonedFromNumber("-10", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.End), "1p", ) assertEquals( - zonedToNumber("q", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("q", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-1", ) assertEquals( - zonedFromNumber("-1", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-1", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "q", ) assertEquals( - zonedToNumber("r", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("r", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-2", ) assertEquals( - zonedFromNumber("-2", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-2", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "r", ) assertEquals( - zonedToNumber("s", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("s", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-3", ) assertEquals( - zonedFromNumber("-3", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-3", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "s", ) assertEquals( - zonedToNumber("t", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("t", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-4", ) assertEquals( - zonedFromNumber("-4", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-4", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "t", ) assertEquals( - zonedToNumber("u", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("u", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-5", ) assertEquals( - zonedFromNumber("-5", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-5", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "u", ) assertEquals( - zonedToNumber("v", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("v", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-6", ) assertEquals( - zonedFromNumber("-6", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-6", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "v", ) assertEquals( - zonedToNumber("w", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("w", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-7", ) assertEquals( - zonedFromNumber("-7", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-7", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "w", ) assertEquals( - zonedToNumber("x", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("x", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-8", ) assertEquals( - zonedFromNumber("-8", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-8", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "x", ) assertEquals( - zonedToNumber("y", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedToNumber("y", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "-9", ) assertEquals( - zonedFromNumber("-9", TextZonedSignStyle.AsciiStandard, OverpunchLocation.Start), + zonedFromNumber("-9", Some(TextZonedSignStyle.AsciiStandard), OverpunchLocation.Start), "y", ) } @Test def zonedIntAsciiTranslatedEBCDICAllDigits(): Unit = { assertEquals( - zonedToNumber("0", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "0", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "0", ) assertEquals( - zonedFromNumber("0", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "0", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "0", ) assertEquals( - zonedToNumber("1", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "1", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "1", ) assertEquals( - zonedFromNumber("1", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "1", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "1", ) assertEquals( - zonedToNumber("2", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "2", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "2", ) assertEquals( - zonedFromNumber("2", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "2", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "2", ) assertEquals( - zonedToNumber("3", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "3", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "3", ) assertEquals( - zonedFromNumber("3", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "3", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "3", ) assertEquals( - zonedToNumber("4", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "4", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "4", ) assertEquals( - zonedFromNumber("4", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "4", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "4", ) assertEquals( - zonedToNumber("5", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "5", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "5", ) assertEquals( - zonedFromNumber("5", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "5", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "5", ) assertEquals( - zonedToNumber("6", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "6", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "6", ) assertEquals( - zonedFromNumber("6", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "6", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "6", ) assertEquals( - zonedToNumber("7", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "7", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "7", ) assertEquals( - zonedFromNumber("7", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "7", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "7", ) assertEquals( - zonedToNumber("8", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "8", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "8", ) assertEquals( - zonedFromNumber("8", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "8", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "8", ) assertEquals( - zonedToNumber("9", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedToNumber( + "9", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "9", ) assertEquals( - zonedFromNumber("9", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.None), + zonedFromNumber( + "9", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.None, + ), "9", ) assertEquals( - zonedToNumber("{", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "{", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "0", ) assertEquals( - zonedFromNumber("0", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "0", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "{", ) assertEquals( - zonedToNumber("A", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "A", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "1", ) assertEquals( - zonedFromNumber("1", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "1", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "A", ) assertEquals( - zonedToNumber("B", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "B", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "2", ) assertEquals( - zonedFromNumber("2", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "2", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "B", ) assertEquals( - zonedToNumber("C", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "C", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "3", ) assertEquals( - zonedFromNumber("3", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "3", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "C", ) assertEquals( - zonedToNumber("D", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "D", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "4", ) assertEquals( - zonedFromNumber("4", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "4", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "D", ) assertEquals( - zonedToNumber("E", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "E", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "5", ) assertEquals( - zonedFromNumber("5", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "5", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "E", ) assertEquals( - zonedToNumber("F", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "F", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "6", ) assertEquals( - zonedFromNumber("6", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "6", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "F", ) assertEquals( - zonedToNumber("G", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "G", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "7", ) assertEquals( - zonedFromNumber("7", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "7", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "G", ) assertEquals( - zonedToNumber("H", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "H", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "8", ) assertEquals( - zonedFromNumber("8", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "8", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "H", ) assertEquals( - zonedToNumber("I", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "I", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "9", ) assertEquals( - zonedFromNumber("9", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "9", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "I", ) assertEquals( - zonedToNumber("1}", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedToNumber( + "1}", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), "-10", ) assertEquals( - zonedFromNumber("-10", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.End), + zonedFromNumber( + "-10", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.End, + ), "1}", ) assertEquals( - zonedToNumber("J", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "J", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-1", ) assertEquals( - zonedFromNumber("-1", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-1", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "J", ) assertEquals( - zonedToNumber("K", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "K", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-2", ) assertEquals( - zonedFromNumber("-2", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-2", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "K", ) assertEquals( - zonedToNumber("L", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "L", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-3", ) assertEquals( - zonedFromNumber("-3", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-3", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "L", ) assertEquals( - zonedToNumber("M", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "M", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-4", ) assertEquals( - zonedFromNumber("-4", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-4", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "M", ) assertEquals( - zonedToNumber("N", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "N", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-5", ) assertEquals( - zonedFromNumber("-5", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-5", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "N", ) assertEquals( - zonedToNumber("O", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "O", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-6", ) assertEquals( - zonedFromNumber("-6", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-6", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "O", ) assertEquals( - zonedToNumber("P", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "P", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-7", ) assertEquals( - zonedFromNumber("-7", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-7", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "P", ) assertEquals( - zonedToNumber("Q", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "Q", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-8", ) assertEquals( - zonedFromNumber("-8", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-8", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "Q", ) assertEquals( - zonedToNumber("R", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedToNumber( + "R", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "-9", ) assertEquals( - zonedFromNumber("-9", TextZonedSignStyle.AsciiTranslatedEBCDIC, OverpunchLocation.Start), + zonedFromNumber( + "-9", + Some(TextZonedSignStyle.AsciiTranslatedEBCDIC), + OverpunchLocation.Start, + ), "R", ) } @Test def zonedIntAsciiCARealiaModifiedAllDigits(): Unit = { assertEquals( - zonedToNumber("0", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "0", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "0", ) assertEquals( - zonedFromNumber("0", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "0", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "0", ) assertEquals( - zonedToNumber("1", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "1", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "1", ) assertEquals( - zonedFromNumber("1", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "1", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "1", ) assertEquals( - zonedToNumber("2", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "2", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "2", ) assertEquals( - zonedFromNumber("2", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "2", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "2", ) assertEquals( - zonedToNumber("3", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "3", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "3", ) assertEquals( - zonedFromNumber("3", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "3", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "3", ) assertEquals( - zonedToNumber("4", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "4", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "4", ) assertEquals( - zonedFromNumber("4", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "4", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "4", ) assertEquals( - zonedToNumber("5", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "5", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "5", ) assertEquals( - zonedFromNumber("5", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "5", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "5", ) assertEquals( - zonedToNumber("6", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "6", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "6", ) assertEquals( - zonedFromNumber("6", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "6", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "6", ) assertEquals( - zonedToNumber("7", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "7", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "7", ) assertEquals( - zonedFromNumber("7", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "7", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "7", ) assertEquals( - zonedToNumber("8", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "8", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "8", ) assertEquals( - zonedFromNumber("8", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "8", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "8", ) assertEquals( - zonedToNumber("9", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "9", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "9", ) assertEquals( - zonedFromNumber("9", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "9", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "9", ) assertEquals( - zonedToNumber("1 ", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedToNumber( + "1 ", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), "-10", ) assertEquals( - zonedFromNumber("-10", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.End), + zonedFromNumber( + "-10", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.End, + ), "1 ", ) assertEquals( - zonedToNumber("!", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "!", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-1", ) assertEquals( - zonedFromNumber("-1", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-1", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "!", ) assertEquals( - zonedToNumber("\"", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "\"", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-2", ) assertEquals( - zonedFromNumber("-2", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-2", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "\"", ) assertEquals( - zonedToNumber("#", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "#", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-3", ) assertEquals( - zonedFromNumber("-3", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-3", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "#", ) assertEquals( - zonedToNumber("$", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "$", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-4", ) assertEquals( - zonedFromNumber("-4", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-4", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "$", ) assertEquals( - zonedToNumber("%", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "%", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-5", ) assertEquals( - zonedFromNumber("-5", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-5", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "%", ) assertEquals( - zonedToNumber("&", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "&", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-6", ) assertEquals( - zonedFromNumber("-6", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-6", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "&", ) assertEquals( - zonedToNumber("'", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "'", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-7", ) assertEquals( - zonedFromNumber("-7", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-7", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "'", ) assertEquals( - zonedToNumber("(", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + "(", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-8", ) assertEquals( - zonedFromNumber("-8", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-8", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "(", ) assertEquals( - zonedToNumber(")", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedToNumber( + ")", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), "-9", ) assertEquals( - zonedFromNumber("-9", TextZonedSignStyle.AsciiCARealiaModified, OverpunchLocation.Start), + zonedFromNumber( + "-9", + Some(TextZonedSignStyle.AsciiCARealiaModified), + OverpunchLocation.Start, + ), ")", ) } @Test def zonedIntAsciiTandemModifiedAllDigits(): Unit = { assertEquals( - zonedToNumber("0", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("0", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "0", ) assertEquals( - zonedFromNumber("0", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "0", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "0", ) assertEquals( - zonedToNumber("1", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("1", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "1", ) assertEquals( - zonedFromNumber("1", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "1", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "1", ) assertEquals( - zonedToNumber("2", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("2", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "2", ) assertEquals( - zonedFromNumber("2", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "2", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "2", ) assertEquals( - zonedToNumber("3", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("3", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "3", ) assertEquals( - zonedFromNumber("3", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "3", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "3", ) assertEquals( - zonedToNumber("4", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("4", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "4", ) assertEquals( - zonedFromNumber("4", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "4", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "4", ) assertEquals( - zonedToNumber("5", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("5", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "5", ) assertEquals( - zonedFromNumber("5", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "5", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "5", ) assertEquals( - zonedToNumber("6", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("6", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "6", ) assertEquals( - zonedFromNumber("6", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "6", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "6", ) assertEquals( - zonedToNumber("7", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("7", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "7", ) assertEquals( - zonedFromNumber("7", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "7", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "7", ) assertEquals( - zonedToNumber("8", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("8", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "8", ) assertEquals( - zonedFromNumber("8", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "8", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "8", ) assertEquals( - zonedToNumber("9", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("9", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "9", ) assertEquals( - zonedFromNumber("9", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "9", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "9", ) assertEquals( - zonedToNumber("1€", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedToNumber("1€", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.End), "-10", ) assertEquals( - zonedFromNumber("-10", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.End), + zonedFromNumber( + "-10", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.End, + ), "1€", ) assertEquals( - zonedToNumber("", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-1", ) assertEquals( - zonedFromNumber("-1", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-1", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "", ) assertEquals( - zonedToNumber("‚", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("‚", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-2", ) assertEquals( - zonedFromNumber("-2", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-2", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "‚", ) assertEquals( - zonedToNumber("ƒ", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("ƒ", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-3", ) assertEquals( - zonedFromNumber("-3", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-3", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "ƒ", ) assertEquals( - zonedToNumber("„", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("„", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-4", ) assertEquals( - zonedFromNumber("-4", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-4", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "„", ) assertEquals( - zonedToNumber("…", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("…", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-5", ) assertEquals( - zonedFromNumber("-5", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-5", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "…", ) assertEquals( - zonedToNumber("†", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("†", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-6", ) assertEquals( - zonedFromNumber("-6", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-6", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "†", ) assertEquals( - zonedToNumber("‡", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("‡", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-7", ) assertEquals( - zonedFromNumber("-7", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-7", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "‡", ) assertEquals( - zonedToNumber("ˆ", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("ˆ", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-8", ) assertEquals( - zonedFromNumber("-8", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-8", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "ˆ", ) assertEquals( - zonedToNumber("‰", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedToNumber("‰", Some(TextZonedSignStyle.AsciiTandemModified), OverpunchLocation.Start), "-9", ) assertEquals( - zonedFromNumber("-9", TextZonedSignStyle.AsciiTandemModified, OverpunchLocation.Start), + zonedFromNumber( + "-9", + Some(TextZonedSignStyle.AsciiTandemModified), + OverpunchLocation.Start, + ), "‰", ) } + + @Test def zonedIntEBCDICPos1(): Unit = { + val num = "1" + val result = + zonedToNumber(num, None, OverpunchLocation.Start) + assertEquals("1", result) + assertEquals( + "A", + zonedFromNumber( + result, + None, + OverpunchLocation.Start, + ), + ) + } + + @Test def zonedIntEBCDICPos2(): Unit = { + val num = "12" + val result = + zonedToNumber(num, None, OverpunchLocation.End) + assertEquals(result, "12") + assertEquals( + "1B", + zonedFromNumber( + result, + None, + OverpunchLocation.End, + ), + ) + } + + @Test def zonedIntEBCDICPos3(): Unit = { + val num = "123" + val result = + zonedToNumber(num, None, OverpunchLocation.None) + assertEquals("123", result) + assertEquals( + "123", + zonedFromNumber( + result, + None, + OverpunchLocation.None, + ), + ) + } + + @Test def zonedIntEBCDICPos4(): Unit = { + val num = "A234567890" // A is +1 sign Ebcdic C1. + val result = + zonedToNumber(num, None, OverpunchLocation.Start) + assertEquals("1234567890", result) + assertEquals( + num, + zonedFromNumber( + result, + None, + OverpunchLocation.Start, + ), + ) + } + + @Test def zonedIntEBCDICPos5(): Unit = { + val num = "00000000000123456789{" + val result = + zonedToNumber(num, None, OverpunchLocation.End) + assertEquals("000000000001234567890", result) + assertEquals( + num, + zonedFromNumber( + result, + None, + OverpunchLocation.End, + ), + ) + } + + @Test def zonedIntEBCDICNeg1(): Unit = { + val num = "J" + val result = + zonedToNumber(num, None, OverpunchLocation.Start) + assertEquals(result, "-1") + assertEquals( + zonedFromNumber( + result, + None, + OverpunchLocation.Start, + ), + num, + ) + } + + @Test def zonedIntEBCDICNeg2(): Unit = { + val num = "1K" + val result = + zonedToNumber(num, None, OverpunchLocation.End) + assertEquals(result, "-12") + assertEquals( + zonedFromNumber( + result, + None, + OverpunchLocation.End, + ), + num, + ) + } + + @Test def zonedIntEBCDICNeg3(): Unit = { + val num = "J23" + val result = + zonedToNumber(num, None, OverpunchLocation.Start) + assertEquals(result, "-123") + assertEquals( + zonedFromNumber( + result, + None, + OverpunchLocation.Start, + ), + num, + ) + } + + @Test def zonedIntEBCDICNeg4(): Unit = { + val num = "123456789}" + val result = + zonedToNumber(num, None, OverpunchLocation.End) + assertEquals(result, "-1234567890") + assertEquals( + zonedFromNumber( + result, + None, + OverpunchLocation.End, + ), + num, + ) + } + + @Test def zonedIntEBCDICNeg5(): Unit = { + val num = "}00000000001234567890" + val result = + zonedToNumber(num, None, OverpunchLocation.Start) + assertEquals(result, "-000000000001234567890") + assertEquals( + zonedFromNumber( + result, + None, + OverpunchLocation.Start, + ), + num, + ) + } + + @Test def zonedIntEBCDICInvalidDigit(): Unit = { + val num = "z123" + try { + zonedToNumber( + num, + None, + OverpunchLocation.Start, + ) + } catch { + case nfe: NumberFormatException => + assertTrue(nfe.getMessage().contains("Invalid zoned digit")) + } + } + + @Test def zonedIntEBCDICInvalidOverpunchInMiddle(): Unit = { + val num = "1K3" // K is normally an overpunched -2 (ebcdic D2) + try { + zonedToNumber( + num, + None, + OverpunchLocation.Start, + ).toInt // error is detected by toInt call since 1K3 isn't convertible. + fail("Did not detect number format exception") + } catch { + case nfe: NumberFormatException => + val m = nfe.getMessage() + assertTrue(m.contains("1K3")) + } + } + + @Test def zonedIntEBCDICAllDigits(): Unit = { + assertEquals( + zonedToNumber("0", None, OverpunchLocation.Start), + "0", + ) + assertEquals( + zonedToNumber("{", None, OverpunchLocation.Start), + "0", + ) + assertEquals( + zonedFromNumber( + "0", + None, + OverpunchLocation.Start, + ), + "{", + ) + assertEquals( + zonedToNumber("1", None, OverpunchLocation.Start), + "1", + ) + assertEquals( + zonedToNumber("A", None, OverpunchLocation.Start), + "1", + ) + assertEquals( + zonedFromNumber( + "1", + None, + OverpunchLocation.Start, + ), + "A", + ) + assertEquals( + zonedToNumber("2", None, OverpunchLocation.Start), + "2", + ) + assertEquals( + zonedToNumber("B", None, OverpunchLocation.Start), + "2", + ) + assertEquals( + zonedFromNumber( + "2", + None, + OverpunchLocation.Start, + ), + "B", + ) + assertEquals( + zonedToNumber("3", None, OverpunchLocation.Start), + "3", + ) + assertEquals( + zonedToNumber("C", None, OverpunchLocation.Start), + "3", + ) + assertEquals( + zonedFromNumber( + "3", + None, + OverpunchLocation.Start, + ), + "C", + ) + assertEquals( + zonedToNumber("4", None, OverpunchLocation.Start), + "4", + ) + assertEquals( + zonedToNumber("D", None, OverpunchLocation.Start), + "4", + ) + assertEquals( + zonedFromNumber( + "4", + None, + OverpunchLocation.Start, + ), + "D", + ) + assertEquals( + zonedToNumber("5", None, OverpunchLocation.Start), + "5", + ) + assertEquals( + zonedToNumber("E", None, OverpunchLocation.Start), + "5", + ) + assertEquals( + zonedFromNumber( + "5", + None, + OverpunchLocation.Start, + ), + "E", + ) + assertEquals( + zonedToNumber("6", None, OverpunchLocation.Start), + "6", + ) + assertEquals( + zonedToNumber("F", None, OverpunchLocation.Start), + "6", + ) + assertEquals( + zonedFromNumber( + "6", + None, + OverpunchLocation.Start, + ), + "F", + ) + assertEquals( + zonedToNumber("7", None, OverpunchLocation.Start), + "7", + ) + assertEquals( + zonedToNumber("G", None, OverpunchLocation.Start), + "7", + ) + assertEquals( + zonedFromNumber( + "7", + None, + OverpunchLocation.Start, + ), + "G", + ) + assertEquals( + zonedToNumber("8", None, OverpunchLocation.Start), + "8", + ) + assertEquals( + zonedToNumber("H", None, OverpunchLocation.Start), + "8", + ) + assertEquals( + zonedFromNumber( + "8", + None, + OverpunchLocation.Start, + ), + "H", + ) + assertEquals( + zonedToNumber("9", None, OverpunchLocation.Start), + "9", + ) + assertEquals( + zonedToNumber("I", None, OverpunchLocation.Start), + "9", + ) + assertEquals( + zonedFromNumber( + "9", + None, + OverpunchLocation.Start, + ), + "I", + ) + assertEquals( + zonedToNumber("1}", None, OverpunchLocation.End), + "-10", + ) + assertEquals( + zonedToNumber("1^", None, OverpunchLocation.End), + "-10", + ) + assertEquals( + zonedFromNumber( + "-10", + None, + OverpunchLocation.End, + ), + "1}", + ) + assertEquals( + zonedToNumber("J", None, OverpunchLocation.Start), + "-1", + ) + assertEquals( + zonedToNumber("£", None, OverpunchLocation.Start), + "-1", + ) + assertEquals( + zonedFromNumber( + "-1", + None, + OverpunchLocation.Start, + ), + "J", + ) + assertEquals( + zonedToNumber("K", None, OverpunchLocation.Start), + "-2", + ) + assertEquals( + zonedToNumber("¥", None, OverpunchLocation.Start), + "-2", + ) + assertEquals( + zonedFromNumber( + "-2", + None, + OverpunchLocation.Start, + ), + "K", + ) + assertEquals( + zonedToNumber("L", None, OverpunchLocation.Start), + "-3", + ) + assertEquals( + zonedToNumber("·", None, OverpunchLocation.Start), + "-3", + ) + assertEquals( + zonedFromNumber( + "-3", + None, + OverpunchLocation.Start, + ), + "L", + ) + assertEquals( + zonedToNumber("M", None, OverpunchLocation.Start), + "-4", + ) + assertEquals( + zonedToNumber("©", None, OverpunchLocation.Start), + "-4", + ) + assertEquals( + zonedFromNumber( + "-4", + None, + OverpunchLocation.Start, + ), + "M", + ) + assertEquals( + zonedToNumber("N", None, OverpunchLocation.Start), + "-5", + ) + assertEquals( + zonedToNumber("§", None, OverpunchLocation.Start), + "-5", + ) + assertEquals( + zonedFromNumber( + "-5", + None, + OverpunchLocation.Start, + ), + "N", + ) + assertEquals( + zonedToNumber("O", None, OverpunchLocation.Start), + "-6", + ) + assertEquals( + zonedToNumber("¶", None, OverpunchLocation.Start), + "-6", + ) + assertEquals( + zonedFromNumber( + "-6", + None, + OverpunchLocation.Start, + ), + "O", + ) + assertEquals( + zonedToNumber("P", None, OverpunchLocation.Start), + "-7", + ) + assertEquals( + zonedToNumber("¼", None, OverpunchLocation.Start), + "-7", + ) + assertEquals( + zonedFromNumber( + "-7", + None, + OverpunchLocation.Start, + ), + "P", + ) + assertEquals( + zonedToNumber("Q", None, OverpunchLocation.Start), + "-8", + ) + assertEquals( + zonedToNumber("½", None, OverpunchLocation.Start), + "-8", + ) + assertEquals( + zonedFromNumber( + "-8", + None, + OverpunchLocation.Start, + ), + "Q", + ) + assertEquals( + zonedToNumber("R", None, OverpunchLocation.Start), + "-9", + ) + assertEquals( + zonedToNumber("¾", None, OverpunchLocation.Start), + "-9", + ) + assertEquals( + zonedFromNumber( + "-9", + None, + OverpunchLocation.Start, + ), + "R", + ) + } + } diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/ConvertZonedNumberUnparser.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/ConvertZonedNumberUnparser.scala index 6b985f764f..e4c5ec6f93 100644 --- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/ConvertZonedNumberUnparser.scala +++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/unparsers/runtime1/ConvertZonedNumberUnparser.scala @@ -45,7 +45,7 @@ case class ConvertZonedCombinatorUnparser( case class ConvertZonedNumberUnparser( opl: OverpunchLocation.Value, - zonedSignStyle: TextZonedSignStyle, + optZonedSignStyle: Option[TextZonedSignStyle], override val context: ElementRuntimeData, override val textDecimalVirtualPoint: Int, ) extends PrimUnparser @@ -70,7 +70,7 @@ case class ConvertZonedNumberUnparser( val value = scaledNum.toString - val strRep = DecimalUtils.zonedFromNumber(value, zonedSignStyle, opl) + val strRep = DecimalUtils.zonedFromNumber(value, optZonedSignStyle, opl) node.overwriteDataValue(strRep) } diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/ZonedTextParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/ZonedTextParsers.scala index afdd558f04..6cbf2606f1 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/ZonedTextParsers.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/ZonedTextParsers.scala @@ -52,7 +52,7 @@ case class ConvertZonedCombinatorParser( case class ConvertZonedNumberParser( opl: OverpunchLocation.Value, textNumberFormatEv: TextNumberFormatEv, - zonedSignStyle: TextZonedSignStyle, + optZonedSignStyle: Option[TextZonedSignStyle], override val context: ElementRuntimeData, override val textDecimalVirtualPoint: Int, ) extends TextPrimParser @@ -83,7 +83,7 @@ case class ConvertZonedNumberParser( val decodedNum = try { - DecimalUtils.zonedToNumber(str, zonedSignStyle, opl) + DecimalUtils.zonedToNumber(str, optZonedSignStyle, opl) } catch { case e: NumberFormatException => { PE( diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section13/zoned/zoned2.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section13/zoned/zoned2.tdml new file mode 100644 index 0000000000..71ff8766df --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section13/zoned/zoned2.tdml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + D9 F8 F7 F6 F5 F4 F3 F0 F1 F2 + + + + -98765430.12 + + + + + + + + B5 F8 F7 F6 F5 F4 F3 F0 F1 F2 + + + + -58765430.12 + + + + + + + y876543012 + + + Unable to parse zoned xs:decimal from text + y876543012 + Invalid zoned digit: y + + + + + + + F9 F8 F7 F6 F5 F4 F3 F0 F1 D2 + + + + -98765430.12 + + + + + + + + F9 F8 F7 F6 F5 F4 F3 F0 F1 B2 + + + + -98765430.12 + + + + + + + 987654301r + + + Unable to parse zoned xs:decimal from text + 987654301r + Invalid zoned digit: r + + + + diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section13/zoned/TestZoned.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section13/zoned/TestZoned.scala index 3a5d43bf21..b52e0699a8 100644 --- a/daffodil-test/src/test/scala/org/apache/daffodil/section13/zoned/TestZoned.scala +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section13/zoned/TestZoned.scala @@ -25,6 +25,7 @@ import org.junit.Test object TestZoned { val testDir = "/org/apache/daffodil/section13/zoned/" val runner = Runner(testDir, "zoned.tdml") + val eRunner = Runner(testDir, "zoned2.tdml") @AfterClass def shutdown(): Unit = { runner.reset @@ -99,4 +100,27 @@ class TestZoned { @Test def testZonedTandemModified03(): Unit = { runner.runOneTest("ZonedTandemModified03") } @Test def testZonedTandemModified04(): Unit = { runner.runOneTest("ZonedTandemModified04") } @Test def testZonedTandemModified05(): Unit = { runner.runOneTest("ZonedTandemModified05") } + + @Test def testZonedEBCDICLeadingOverpunchedSign(): Unit = { + eRunner.runOneTest("ZonedEBCDICLeadingOverpunchedSign") + } + + @Test def testZonedEBCDICLeadingOverpunchedSign_B5(): Unit = { + eRunner.runOneTest("ZonedEBCDICLeadingOverpunchedSign_B5") + } + + @Test def testZonedEBCDICLeadingOverpunchedSignBadDigit(): Unit = { + eRunner.runOneTest("ZonedEBCDICLeadingOverpunchedSignBadDigit") + } + @Test def testZonedEBCDICTrailingOverpunchedSign(): Unit = { + eRunner.runOneTest("ZonedEBCDICTrailingOverpunchedSign") + } + + @Test def testZonedEBCDICTrailingOverpunchedSign_B2(): Unit = { + eRunner.runOneTest("ZonedEBCDICTrailingOverpunchedSign_B2") + } + @Test def testZonedEBCDICTrailingOverpunchedSignBadDigit(): Unit = { + eRunner.runOneTest("ZonedEBCDICTrailingOverpunchedSignBadDigit") + } + }