Skip to content

Commit

Permalink
WSHUB-458: reader unit tests: Simplify the example reader
Browse files Browse the repository at this point in the history
We simplify this reader in two ways:
1. we remove the `consumed` member of `struct Input`, and instead use
   the `CborValue`'s `source.token` member, which we treat as an
   unsigned integer offset into our `QByteArray`.
2. we replace the reader-specific `struct Input` with the `QByteArray`
   it was wrapping, since that's the only thing now contained in our
   `struct Input`.

If a `CborValue` gets cloned, the pointer referred to by `source.token`
similarly gets cloned, thus when we advance the pointer on the clone, it
leaves the original alone, so computing the length of unknown-length
entities in the CBOR document can be done safely.
  • Loading branch information
sjlongland committed Jul 3, 2021
1 parent 4a1cfc3 commit dcb1091
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions tests/parser/tst_parser.cpp

0 comments on commit dcb1091

Please sign in to comment.