72 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <deque>10 11// deque& operator=(const deque& c);12 13#include "asan_testing.h"14#include <deque>15#include <cassert>16#include "test_macros.h"17#include "test_allocator.h"18#include "min_allocator.h"19 20template <class C>21void test(const C& x) {22 C c;23 c = x;24 assert(c == x);25 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));26 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(x));27}28 29int main(int, char**) {30 {31 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};32 int* an = ab + sizeof(ab) / sizeof(ab[0]);33 test(std::deque<int>(ab, an));34 }35 {36 std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));37 std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));38 l2 = l;39 assert(l2 == l);40 assert(l2.get_allocator() == test_allocator<int>(3));41 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l));42 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l2));43 }44 {45 std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));46 std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));47 l2 = l;48 assert(l2 == l);49 assert(l2.get_allocator() == other_allocator<int>(5));50 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l));51 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l2));52 }53#if TEST_STD_VER >= 1154 {55 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};56 int* an = ab + sizeof(ab) / sizeof(ab[0]);57 test(std::deque<int, min_allocator<int>>(ab, an));58 }59 {60 std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());61 std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());62 l2 = l;63 assert(l2 == l);64 assert(l2.get_allocator() == min_allocator<int>());65 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l));66 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(l2));67 }68#endif69 70 return 0;71}72