Sha256: 5e98905e5df842c8de9412febe8a45c1462b57ec808bc784013ca5e7e4f23b3e
Contents?: true
Size: 1.41 KB
Versions: 11
Compression:
Stored size: 1.41 KB
Contents
#include "unittest.hpp" #include "rice/Allocation_Strategies.hpp" using namespace Rice; namespace { bool constructor_called = false; bool destructor_called = false; class Foo { public: Foo() { constructor_called = true; } ~Foo() { destructor_called = true; } }; } // namespace TESTSUITE(Allocation_Strategies); SETUP(Allocation_Strategies) { ruby_init(); constructor_called = false; destructor_called = false; } TESTCASE(default_allocation_strategy_allocate) { Foo * t = Default_Allocation_Strategy<Foo>::allocate(); ASSERT(constructor_called); ASSERT(!destructor_called); delete t; ASSERT(constructor_called); ASSERT(destructor_called); } TESTCASE(default_allocation_strategy_free) { Foo * t = new Foo; ASSERT(constructor_called); ASSERT(!destructor_called); Default_Allocation_Strategy<Foo>::free(t); ASSERT(constructor_called); ASSERT(destructor_called); } TESTCASE(xmalloc_allocation_strategy_allocate) { Foo * t = Xmalloc_Allocation_Strategy<Foo>::allocate(); ASSERT(constructor_called); ASSERT(!destructor_called); t->~Foo(); xfree(t); ASSERT(constructor_called); ASSERT(destructor_called); } TESTCASE(xmalloc_allocation_strategy_free) { Foo * t = Xmalloc_Allocation_Strategy<Foo>::allocate(); ASSERT(constructor_called); ASSERT(!destructor_called); Xmalloc_Allocation_Strategy<Foo>::free(t); ASSERT(constructor_called); ASSERT(destructor_called); }
Version data entries
11 entries across 11 versions & 3 rubygems