I have a complex struct eg.
struct Data{
std::unordered_map<string, int> map1;
shared_ptr<ClassA> ptrA;
shared_ptr<ClassB> ptrB;
...
};
Inside the code, at a particular iteration, I want to store the state of the struct. This will be done once and that is it.
I want to use this state in my test case as the input.
eg. test.cpp
Data StoredState;
UnitTest(){
...
// do something with StoredState
...
}
Question - What is the best way to store the data and use it in my test file.
The only way that comes to my mind is, write each fields of the struct to files, and manually fill in the StoredState
, which I think is cumbersome. Is there a better way to achieve this.