Giter Club home page Giter Club logo

cbor-test-vectors's Introduction

cbor-test-vectors

Reporitory of encoded CBOR values in machine-processable form for parser testing. See vectors.json.

The basis of the repository are the examples from Appendix A of RFC 8949. All examples in Appendix A of RFC 7049, encoded as a JSON array.

Each element of the test vector is a test case map (JSON object) with the keys:

  • hex: HEX encoded CBOR data
  • flags: Set of these flags (some are mutually exclusive):
    • valid: This is valid and should be parseable by any parser that has all required features
    • invalid: This is invalid and should not be parsed under any circumstances
    • canonical: This value, as it is, is canonically encoded (description of what is canonical)
    • float: The diagnostic contains floating point numbers. Since formatting floats greatly differs from platform to platform and is not always easily configurable, you may want to special-case failures on these tests.
  • features: Each parser is built with different purpose in mind and may handle corner-cases differently. This is a set of features, which are present in this CBOR value. If your parser does not support all features of a test case, it may be OK to skip that test.
    • When the tag begins prefixed with ! it means that the test case is relevant only when the feature is NOT implemented by the parser.
    • int63: Major type 0 and 1 with precision up to -2^63..2^63-1 (integers representable by signed int64, e.g. Java's long)
    • int64: Major type 0 and 1 with full precision, -2^64..2^64-1 (typically requires special care by the implementation and may not be as efficient)
    • mapdupes: Duplicate keys in maps
    • simple: Support for simple values (major 7) other than true, false, null and undefined
    • float16: Support for reading and writing float16 format (in major 7)
    • bignum: Support for parsing tags 2 and 3 as numbers of arbitrary precision
  • diagnostic: The representation of the data item in CBOR diagnostic notation, without encoding marks.
    • Strings use JSON syntax with only mandatory escapes (see ECMA-404). The file itself is encoded using UTF-8.
  • diagnosticExact: Same as diagnostic, but contains all encoding markers.
  • canonical: When the test case is not canonical (flags does not contain canonical), encoding it in canonical form will yield this CBOR HEX encoding

Expected features

These features are expected to always work (are not flagged with a feature flag):

  • Major type 0 and 1 (unsigned and negative integer) with precision up to ±2^53 (integers representable by float64, e.g. JavaScript's number)
  • Major type 2 (byte string) with definite and indefinite length
  • Major type 3 (UTF-8 text) with definite and indefinite length, checking for UTF-8 validity is not required
  • Major type 4 (array) with definite and indefinite length
  • Major type 5 (map) with definite and indefinite length with support of any key-value types, support for duplicate keys is not required
  • Major type 6 (tag) without any explicit support for tag semantics (just preserving the tag is enough)
  • Major type 7 (simple & float) float32 and float64 is required, float16 is optional. Support for simple values outlined in main RFC (true, false, null, undefined), support for other simple values (that are without RFC assigned meaning) is not required.

Given the nature of the test value repository, size limits are unlikely to be a problem.

cbor-test-vectors's People

Contributors

cabo avatar darkyenus avatar hildjj avatar nelsonxb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.