For a test framework, I allow to declare test groups and tests. I'm using a combination of macros and base classes. Tests relate to test groups.
My objective is to have the lowest possible RAM consumption and avoid the use of libraries as much as possible. Currently, only a few bytes are required per test for the test framework itself.
From the macro, a declared test results in the definition of a subclass and the declaration of an object of that subclass. The test is executed when the object is constructed.
So far so good. The tests are executed. I can accumulate results. Two more points are on my wish list though.
- As per my understanding, I cannot rely on the order of the execution (aka initialisation). I'd like to change that.
- Tests are executed before
main()
and I would like to see an explicit control of necessary common preparation inmain()
. I can fall back to having all test groups call a common initialisation method that has a flag whether it was already called, of course.
I seem to think that collecting the tests in a data structure would be a step in the right direction. Problem is, due to the notation, they are spread across the source code, and I do not want them to register at startup (aka run time) because that consumes RAM. So would there be a way in C11 to make them register at compile time?
I looked at:
- https://stackoverflow.com/a/36401358/1856738 which is neither portable nor a solution for me
- https://stackoverflow.com/a/60003650/1856738 which is not portable
- https://stackoverflow.com/a/60003650/1856738 which is not helpful
- https://stackoverflow.com/a/60003650/1856738 which has different preconditions
Aucun commentaire:
Enregistrer un commentaire