2021-08-22 17:03:03 +00:00
|
|
|
#ifndef POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|
|
|
|
#define POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|
|
|
|
|
2021-08-23 19:44:59 +00:00
|
|
|
struct TestEnvironment {
|
2021-08-24 19:19:44 +00:00
|
|
|
size_t TotalRequirements = 0;
|
|
|
|
size_t FailedRequirements = 0;
|
2021-08-23 19:44:59 +00:00
|
|
|
|
|
|
|
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;
|
2021-08-22 17:03:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // POKEMONSCRIPTTESTER_TESTENVIRONMENT_HPP
|