32 lines
791 B
C++
32 lines
791 B
C++
#ifndef POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|
|
#define POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|
|
|
|
struct TestEnvironment {
|
|
size_t TotalRequirements = 0;
|
|
size_t FailedRequirements = 0;
|
|
|
|
template <typename T> void AddGarbage(T* data) { _garbage.Append(GarbageObject(data)); }
|
|
|
|
void CollectGarbage() {
|
|
for (auto& o : _garbage) {
|
|
o.Destructor(o.Ptr);
|
|
}
|
|
_garbage.Clear();
|
|
}
|
|
|
|
private:
|
|
struct GarbageObject {
|
|
void* Ptr;
|
|
std::function<void(void* ptr)> Destructor;
|
|
|
|
template <typename T> GarbageObject(T* ptr) {
|
|
Ptr = ptr;
|
|
Destructor = [](void* v) { delete static_cast<T*>(v); };
|
|
}
|
|
};
|
|
|
|
ArbUt::List<GarbageObject> _garbage;
|
|
};
|
|
|
|
#endif // POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|