jeudi 27 mai 2021

Construct a list, set, array or similar, at compile time, from distributed elements

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.

  1. As per my understanding, I cannot rely on the order of the execution (aka initialisation). I'd like to change that.
  2. Tests are executed before main() and I would like to see an explicit control of necessary common preparation in main(). 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:

Aucun commentaire:

Enregistrer un commentaire