Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-352

Test round-tripping of BSON types with native representations using the BSON corpus data

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.1.0
    • Component/s: None
    • Labels:

      Description

      The BSON corpus test runner is written to follow the specification instructions for a language with no native intermediate representation of BSON. While it is true we do not have a native representation of a document, since we just wrap bson_t s which are already stored in BSON format, we do have native representations of all the other BSON types.

      We should implement the round trip tests for languages with native representations by adding assertions that do something like:
      1. Parse a document from the raw data
      2. Recursively convert the document to a [String: BSONValue]. This will convert every stored value to a native Swift type. (I don't think we can use the decoder here, as it will not recursively parse nested documents into maps.)
      3. Recursively convert the [String: BSONValue] back into a document. This will encode every stored value back to BSON. 
      4. Check that the new document matches the input

      (Note: may need to do something special to preserve key order since dictionaries don't guarantee it)

      This would allow us to catch bugs like SWIFT-351 for example – there are BSON corpus cases for multi-byte UTF8, and converting the stored strings to Swift strings and then putting them back into documents would have shown us that we cut off the end of string.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: