BDE 4.14.0 Production release
|
Provide an allocating test class used to test emplace
methods.
This component provides a (value-semantic) attribute class, bsltf::AllocEmplacableTestType
, that is used to ensure that arguments are forwarded correctly to a type's constructor. This component is similar to bsltf_emplacabletesttype , but provides a type that allocates on construction.
In this section we show intended use of this component.
In this example, we will utilize bsltf::AllocEmplacableTestType
to test the implementation of a container's emplace
method.
First, we create an elided definition of a container class, MyContainer
, and show the signature of the emplace
method we intend to test:
Then, we provide test machinery that will invoke the emplace
method with variable number of arguments:
Here, we use AllocEmplacableTestType
as the contained type to ensure the arguments to the emplace
method are correctly forwarded to the contained type's constructor:
Then, we call emplace
supplying test arguments, which should call the correct constructor of AllocEmplacableTestType
(which we will later verify):
We verify the correct arguments were forwarded to the AllocEmplcableTestType
:
Finally, we call our templatized test case helper with a variety of template arguments: