17 #ifndef AGXUNIT_CONTAINERTESTS_H 18 #define AGXUNIT_CONTAINERTESTS_H 35 agxThrow std::runtime_error(
agx::String::format(
"AlwaysFailingAllocator called with numBytes %lu\n and alignment %lu.", numBytes, alignment));
60 for (
size_t i = 0; i < 4; ++i) {
63 size_t oldCapacity = t.capacity();
64 void* oldPtr = (
void*)t.ptr();
66 bool hasBeenInException =
false;
75 catch (std::exception& e)
77 std::cout <<
"\nCaught (intentionally provoked) exception: " << e.what() << std::endl;
78 hasBeenInException =
true;
108 #if 0 // This test will fail in many containers. \todo: Fix containers! 110 for (
size_t i = 0; i < 2; ++i) {
115 size_t oldCapacity = t.capacity();
116 void* oldPtr = (
void*)t.ptr();
118 bool hasBeenInException =
false;
124 t.reserve(tooBigToAlloc);
126 oldCapacity = t.capacity();
127 oldPtr = (
void*)t.ptr();
129 catch (std::exception& e)
131 std::cout <<
"\nCaught (intentionally provoked) exception: " << e.what() << std::endl;
132 hasBeenInException =
true;
134 if (hasBeenInException) {
140 const size_t minNewCapacity = oldCapacity + tooBigToAlloc;
142 agx::String::format(
"Did not reserve enough capacity, wanted: %lu; reserved: %lu.\n", minNewCapacity, t.capacity()),
143 t.capacity() >= minNewCapacity);
The Container is the base class for several of the container classes proided by AGX, such as agx::Vector and agx::HashSet.
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
#define AGXUNIT_ASSERT_MESSAGE(message, condition)
Report error (with additional message) if condition returns false.
#define AGXUNIT_BEGIN_TEST(X)
Begin a new named test. Name (X) must be unique through all tests.
void setContainer(class agx::Container *)
void deallocateBytes(void *, size_t)
void testBadAlloc(const agx::String &)
The purpose of this test is to test how the container recovers from bad alloc.
Never allocates anything, throws always an exception. Only for testing.
void testAllocationOverflow(const agx::String &)
The purpose of this test is to test for overflow in allocation size.
#define AGXUNIT_END_TEST(X)
End a named test.
void * allocateBytes(size_t numBytes, size_t alignment=16)
static AgXString format(const char *format,...)
C printf formatting of a string.