diff --git a/test/unittest/allocatorstest.cpp b/test/unittest/allocatorstest.cpp index ec1b2ce..2ffc325 100644 --- a/test/unittest/allocatorstest.cpp +++ b/test/unittest/allocatorstest.cpp @@ -16,8 +16,10 @@ #include "rapidjson/allocators.h" +#include #include -#include +#include +#include using namespace rapidjson; @@ -141,12 +143,34 @@ void TestStdAllocator(const Allocator& a) { typedef StdAllocator CharAllocator; typedef std::basic_string, CharAllocator> String; +#if RAPIDJSON_HAS_CXX11 + String s(CharAllocator{a}); +#else CharAllocator ca(a); String s(ca); +#endif for (int i = 0; i < 26; i++) { s.push_back(static_cast('A' + i)); } EXPECT_TRUE(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + typedef StdAllocator, Allocator> MapAllocator; + typedef std::map, MapAllocator> Map; +#if RAPIDJSON_HAS_CXX11 + Map map(std::less(), MapAllocator{a}); +#else + MapAllocator ma(a); + Map map(std::less(), ma); +#endif + for (int i = 0; i < 10; i++) { + map.insert(std::make_pair(i, (i % 2) == 0)); + } + EXPECT_TRUE(map.size() == 10); + for (int i = 0; i < 10; i++) { + typename Map::iterator it = map.find(i); + EXPECT_TRUE(it != map.end()); + EXPECT_TRUE(it->second == ((i % 2) == 0)); + } } TEST(Allocator, CrtAllocator) {