diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 2553a4bed..6de79871c 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -262,60 +262,64 @@ TEST_CASE("bad my_allocator::construct") } } -namespace{ - template - struct NAlloc { - // Aliases and inner types - using value_type = T; - using size_type = std::size_t; - using difference_type = ptrdiff_t; - using reference = value_type&; - using const_reference = const value_type&; - using pointer = value_type*; - using const_pointer = const value_type*; +namespace +{ +template +struct NAlloc +{ + // Aliases and inner types + using value_type = T; + using size_type = std::size_t; + using difference_type = ptrdiff_t; + using reference = value_type&; + using const_reference = const value_type&; + using pointer = value_type*; + using const_pointer = const value_type*; - template - struct rebind { - using other = NAlloc; - }; - - NAlloc() : - alloc() { - - }; - - virtual ~NAlloc() { } - - pointer allocate(std::size_t n) { - #ifdef _DEBUG - std::cout << "NAlloc allocating " << n << " bytes\n"; - #endif - - return static_cast(alloc.allocate(n)); // get memory from pool - } - void deallocate(pointer p, [[maybe_unused]] std::size_t n) { - #ifdef _DEBUG - std::cout << "NAlloc deallocating " << n * sizeof *p << " bytes\n"; - #endif - - alloc.deallocate(static_cast(p), 1); // return memory to pool - } - - - bool operator!=(const NAlloc& other) const { - return !(*this == other); - } - bool operator==(const NAlloc& other) const { - return alloc == other.alloc; - } - - my_allocator alloc; + template + struct rebind + { + using other = NAlloc; }; + NAlloc() : + alloc() + { - using OstringStream = std::basic_ostringstream, NAlloc>; - using IstringStream = std::basic_istringstream, NAlloc>; - typedef std::basic_string, NAlloc> RtString; + }; + + virtual ~NAlloc() { } + + pointer allocate(std::size_t n) + { + + + return static_cast(alloc.allocate(n)); // get memory from pool + } + void deallocate(pointer p, [[maybe_unused]] std::size_t n) + { + + + alloc.deallocate(static_cast(p), 1); // return memory to pool + } + + + bool operator!=(const NAlloc& other) const + { + return !(*this == other); + } + bool operator==(const NAlloc& other) const + { + return alloc == other.alloc; + } + + my_allocator alloc; +}; + + +using OstringStream = std::basic_ostringstream, NAlloc>; +using IstringStream = std::basic_istringstream, NAlloc>; +typedef std::basic_string, NAlloc> RtString; } @@ -332,11 +336,11 @@ TEST_CASE("controlled bad_alloc_rt_string") double, my_allocator>; - + SECTION("class json_value") { - + SECTION("json_value(value_t)") { SECTION("object")