| 97 | } |
| 98 | |
| 99 | void copy_assignment() // assignment |
| 100 | { |
| 101 | char buffer[1024]; |
| 102 | std::pmr::monotonic_buffer_resource pool{ std::data(buffer), std::size(buffer) }; |
| 103 | std::pmr::polymorphic_allocator<char> alloc(&pool); |
| 104 | |
| 105 | char buffer1[1024]; |
| 106 | std::pmr::monotonic_buffer_resource pool1{ std::data(buffer1), std::size(buffer1) }; |
| 107 | std::pmr::polymorphic_allocator<char> alloc1(&pool1); |
| 108 | |
| 109 | jsoncons::pmr::json j{ "String too long for short string", alloc }; |
| 110 | assert(j.is_string()); |
| 111 | assert(j.get_allocator().resource() == &pool); |
| 112 | |
| 113 | // copy long string to number |
| 114 | jsoncons::pmr::json j1{10}; |
| 115 | j1 = j; |
| 116 | assert(j1.is_string()); |
| 117 | assert(j1.get_allocator() == std::allocator_traits<std::pmr::polymorphic_allocator<char>>:: |
| 118 | select_on_container_copy_construction(j.get_allocator())); |
| 119 | assert(j1.get_allocator() == std::pmr::polymorphic_allocator<char>{}); |
| 120 | |
| 121 | // copy long string to array |
| 122 | jsoncons::pmr::json j2{ jsoncons::json_array_arg, {1,2,3,4}, |
| 123 | jsoncons::semantic_tag::none, alloc1}; |
| 124 | j2 = j; |
| 125 | assert(j2.is_string()); |
| 126 | assert(j2.get_allocator().resource() == &pool1); |
| 127 | } |
| 128 | |
| 129 | void move_assignment() // assignment |
| 130 | { |
no test coverage detected