#include #include #include #include #include #include #include TEST(Standard_StdAllocatorTestSuite, testTraits) { //type definitions typedef Handle_Standard_Transient elem_type; typedef Standard_StdAllocator allocator_type; ASSERT_EQ(sizeof (allocator_type::value_type),sizeof (elem_type)); ASSERT_EQ(sizeof (allocator_type::pointer),sizeof (void*)); ASSERT_EQ(sizeof (allocator_type::const_pointer),sizeof (void*)); ASSERT_EQ(sizeof (allocator_type::size_type),sizeof (size_t)); ASSERT_EQ(sizeof (allocator_type::difference_type),sizeof (ptrdiff_t)); typedef int other_elem_type; ASSERT_EQ(sizeof (allocator_type::rebind::other::value_type), sizeof (other_elem_type)); } TEST(Standard_StdAllocatorTestSuite, testContainers) { //typed allocator std::list > aL; TopoDS_Solid aSolid = (TopoDS_Solid) BRepPrimAPI_MakeBox (10., 20., 30.); aL.push_back (aSolid); ASSERT_EQ(aL.size(), size_t (1)); //type cast Standard_StdAllocator aCAlloc; std::vector > aV (aCAlloc); aV.push_back(1); ASSERT_EQ(aV.size(), size_t (1)); //using void-specialization allocator std::vector > aV2; aV2.resize(10); aV2.push_back(-1); ASSERT_EQ(aV2.size(), size_t (11)); } int main(int argc, char **argv){ testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }