This idea was informally described in the PR for the rewrite (#6), but it requires a few annoying changes. Basically, I would like to:
- Allow the KDL schema to specify one or more example JSONs. This is a trivial parser change.
- Allow the generators to use this additional information:
- Include the example JSON in the documentation for the resulting
class/struct. Also trivial.
- 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.
This idea was informally described in the PR for the rewrite (#6), but it requires a few annoying changes. Basically, I would like to:
class/struct. Also trivial.The last point is blocked on #23.
KDL syntax
I image it would be something like this:
It may make sense to consider adding some optional attributes (something like
is-wrong=#trueto expect an error), but it would be extremely low priority and maybe useless.Test generators
Unfortunately this requires the
Addonto 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.