Well i have this function overload:
static bool returnNull;
void* operator new(const std::size_t size, const std::nothrow_t&) noexcept
{
void* address{ nullptr };
if (!returnNull)
{
address = operator new(size);
}
return address;
}
And i want to make something like:
void* operator new(const std::size_t size, const std::nothrow_t&) noexcept
{
if (typeObject == AnimalClass)
return nullptr;
void* address{ nullptr };
if (!returnNull)
{
address = operator new(size);
}
return address;
}
So, i need this functionality for unit testing a builder that have many new calls, so i want to fail a specific allocation based on Class that should be alocated
Aucun commentaire:
Enregistrer un commentaire