From e2a77ba3c10f58150e93b24b17f6cce6c2fdb618 Mon Sep 17 00:00:00 2001 From: Alex Fishgait Date: Thu, 12 Oct 2023 07:50:09 +0200 Subject: [PATCH] adjust unit test for rtstring --- tests/src/unit-allocator.cpp | 103 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 3b15cfc8c..9efabf83c 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -262,74 +262,75 @@ 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; - }; +// template +// struct rebind +// { +// using other = NAlloc; +// }; - NAlloc() : - alloc() - { +// NAlloc() : +// alloc() +// { - } +// } - NAlloc(const NAlloc&) = default; // Copy constructor - NAlloc(NAlloc&&) = default; // Move constructor - NAlloc& operator=(const NAlloc& other) = default; // Copy assignment operator - NAlloc& operator=(NAlloc&&) = default; // Move assignment operator +// NAlloc(const NAlloc&) = default; // Copy constructor +// NAlloc(NAlloc&&) = default; // Move constructor +// NAlloc& operator=(const NAlloc& other) = default; // Copy assignment operator +// NAlloc& operator=(NAlloc&&) = default; // Move assignment operator - virtual ~NAlloc() = default; +// virtual ~NAlloc() = default; - pointer allocate(std::size_t n) - { +// pointer allocate(std::size_t n) +// { - return static_cast(alloc.allocate(n)); // get memory from pool - } - void deallocate(pointer p, std::size_t n) - { - m_alloc_size = n; - alloc.deallocate(static_cast(p), 1); // return memory to pool - } +// return static_cast(alloc.allocate(n)); // get memory from pool +// } +// void deallocate(pointer p, std::size_t n) +// { +// m_alloc_size = 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; - } +// bool operator!=(const NAlloc& other) const +// { +// return !(*this == other); +// } +// bool operator==(const NAlloc& other) const +// { +// return alloc == other.alloc; +// } - my_allocator alloc; - std::size_t m_alloc_size {}; -}; +// my_allocator alloc; +// std::size_t m_alloc_size {}; +// }; -using OstringStream = std::basic_ostringstream, NAlloc>; -using IstringStream = std::basic_istringstream, NAlloc>; -using RtString = std::basic_string, NAlloc>; +// using OstringStream = std::basic_ostringstream, NAlloc>; +// using IstringStream = std::basic_istringstream, NAlloc>; +// using RtString = std::basic_string, NAlloc>; -} //namespace +// } //namespace TEST_CASE("controlled bad_alloc_rt_string") { + using RtString = std::basic_string, my_allocator>; // create JSON type using the throwing allocator using my_json = nlohmann::basic_json