Loki library tests on sourceforge
On sourceforge one can find a set of tests of the Loki library.
http://cvs.sourceforge.net/viewcvs.py/loki-exp/loki-exp/development/unit-testing/loki_unit_test/.
This software seems to be unchanged for 2 years, and does not compile
out-of-the-box on gcc 3.2.
Here is a list of Loki functionalities testes by the suite.
The desription may be incomplete and/or inaccurate: refer to the
sources for the exact operations.
- AbstractFactory:
Define the abstract hierarchy and two concrete hierarchies: Silly and Bad
Define the abstract factory type and the two concrete factory types,
based on OpNewFactoryUnit.
Test that the concrete factories create the proper types (ie Silly and
Bad, respectively).
- AssocVector:
Define a custom TestAllocator class with methods:
- T* allocate( nr, /* unused */ T* )
- void deallocate( T*, /* unused */ size )
- size_t max()
- void construct( T*, T& )
- void destroy( T* )
Define a TestClass with copy assignment and operator <.
Define a few AssocVector types:
- one of pairs (int, int) using the TestAllocator
- one of pairs (const char *, int) using the TestAllocator
- one of pairs (std::string, std::string)
- one of pairs (TestClass, TestClass) using the TestAllocator
- one of pairs (int, const char *)
Test 1:
- check default constructor (size == 0)
- check inserting an element
- check copy constructor
- check constructor with param compare-fct and allocator
- check swap
- check constr. object on heap and destroying it
Test 2:
- insert several values and check that it is sorted
- check find()
- check that inserting a key again fails
- check erase()
- check clear()
Test 3:
- check inserting a large number of items (2000)
Test 4:
- insert 100 items, and two more items
- check find()
- check swap
- check erase()
Test 5:
- insert 3 items
- check that they are properly inserted at the right position
- Factory:
Define the class hierarchy of Shape's and the methods to create and clone
Define the factory type for the Shape,
register the create functions and test them.
Define the clone factory type for the Shape,
register the clone functions and test them.
- Functor:
Test functors of function, class operator(), class member function,
functor copy constructor.
Test functor binding and chaining.
- Singleton:
Test Singleton with different combinations of cretion policy, lifetime,
and multithreading:
- creation: using new, using malloc, static
- lifetime: default, phoenix, longevity, nodestroy
- thread: single, class-level lock
- SmallObject:
Define a Small class and a Big class, each with a derived class.
Define also a class hierarchy (A, B, C, and D derived from Base
and SmallObject, with, respectively 1, 2, 3, 4 integers).
Test the creation and destruction of objects of Small class and
objects of Big class.
Explicitly test the SmallObject operator new() and operator delete().
There is also a stress test, involving crating and destroying many
objects randomly chosen from the second hierarchy. It is commented.
- TypeManip:
- Check Int2Type
- Check Type2Type
- Check Select
- Check Conversion
- Check SUPERSUBCLASS
- Check SUPERSUBCLASS_STRICT
- TypeTraits:
- Check isPointer
- Check isReference
- Check isMemberPointer
- Check isStdUnsignedInt
- Check isStdSignedInt
- Check isStdIntegral
- Check isStdFloat
- Check isStdArith
- Check isStdFundamental
- Check isUnsignedInt
- Check isSignedInt
- Check isIntegral
- Check isFloat
- Check isArith
- Check isFundamental
- Check isConst
- Check isVolatile
- and tests on SameType
- Typelist:
- Check Length
- Check TypeAt
- Check TypeAtNonStrict
- Check IndexOf
- Check Append
- Check Erase
- Check EraseAll
- Check NoDuplicates
- Check Replace
- Check ReplaceAll
- Check Reverse
- Check MostDerived
- Check DerivedToFront