Skip to content

End-to-end testing roundtrip deserialization #27

@andry-dev

Description

@andry-dev

This idea was informally described in the PR for the rewrite (#6), but it requires a few annoying changes. Basically, I would like to:

  1. Allow the KDL schema to specify one or more example JSONs. This is a trivial parser change.
  2. Allow the generators to use this additional information:
    1. Include the example JSON in the documentation for the resulting class/struct. Also trivial.
    2. Generate C++ code with GTest/Catch2/... that takes that example JSON and passes it through Glaze to end-to-end test the (de)serialization. This is the painful part :)

The last point is blocked on #23.

KDL syntax

I image it would be something like this:

json Foo {
  // ...
  field bar type="str" {
    key "the-key"
    // ...
  }

  example """
  {
    "the-key": "abc"
  }
  """

  example """
  {
    "the-key": "def"
  }
  """
}

It may make sense to consider adding some optional attributes (something like is-wrong=#true to expect an error), but it would be extremely low priority and maybe useless.

Test generators

Unfortunately this requires the Addon to know which testing framework is in use (like, GTest, Catch or whatever is language-specific) and possibly to generate additional files. So, it would require the "complete" solution to #23.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions