Hello, I am currently making a minimalistic testing framework for on-target unit testing. I am making the framework layered, so that a named testing section contains multiple assertions and a named test case contains multiple sections. For every section that is called within a test case, a counter will increment, so that once the test case is finished, the total number of sections can be sent over a communication protocol (e.g. UART), with additional information on each assertion performed in each section.
What I am wondering is, would it be better to place the entire testing framework in a struct with the relevant counters internally, or each function (for naming and incrementing the total number of sections) in a file along with a namespace containing the counters to limit the scope? As I understand it, if I use the struct method, I will get multiple of the same counter variables while in the namespace method I will only have one, where I use various function calls to increment the counter. Would the namespace method be bad practice in some way, or is this the preferred choice?
Below is the code for the namespace method. The create_id_message doesn't require a template, but I used it so that it will be run at compile time. Feel free to comment on any bad practice or improvements I can make, any help would be greatly appreciated :)
The std::cout statements will be changed for communication protocol message functions that are used on-target
Multiple files can share a namespace, and add declarations to that namespace.
Take std for example, file vector adds vector, utility a whole bunch of disparate things, string basic_string. They're just cooperating parts of a library,
A record is defined once and that definition is static.
The only thing struct and namespace have in common is thy define some kind of scope.