You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/02/15 12:50:52 UTC
[GitHub] [daffodil] stevedlawrence commented on a change in pull request #752: Fix and add test cases for prefixed length bugs.
stevedlawrence commented on a change in pull request #752:
URL: https://github.com/apache/daffodil/pull/752#discussion_r806794860
##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala
##########
@@ -108,15 +109,32 @@ trait PrefixedLengthParserMixin {
*/
def getPrefixedLengthInBits(state: PState): Long = {
val lenInUnits = getPrefixedLengthInUnits(state)
- lengthUnits match {
+ val lenInBits = lengthUnits match {
case LengthUnits.Bits => lenInUnits
case LengthUnits.Bytes => lenInUnits * 8
case LengthUnits.Characters => {
val mfw = state.encoder.bitsCharset.maybeFixedWidth
- if (mfw.isDefined) mfw.get
+ if (mfw.isDefined)
+ lenInUnits * mfw.get // fixed, only supported for parsing (maybe)
Review comment:
Should we add a test for this, codecov says there's no coverage.
Also, suggest this slight change to avoid the if-statement and make it I think a bit easier to read.
```scala
Assert.invariant(mfw.isDefined, "Prefixed length for text data in non-fixed width encoding.")
lenInUnits * mfw.get
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org