| 50 | } |
| 51 | |
| 52 | void list_test::test_construction_and_assignment() |
| 53 | { |
| 54 | auto check1 = {1, 1, 1, 1, 1, 1}; |
| 55 | auto check2 = {1, 2, 3, 4, 5, 6}; |
| 56 | |
| 57 | std::list<int> l1(6U, 1); |
| 58 | test_eq( |
| 59 | "n*value initialization", |
| 60 | check1.begin(), check1.end(), |
| 61 | l1.begin(), l1.end() |
| 62 | ); |
| 63 | |
| 64 | std::list<int> l2{check2}; |
| 65 | test_eq( |
| 66 | "initializer_list initialization", |
| 67 | check2.begin(), check2.end(), |
| 68 | l2.begin(), l2.end() |
| 69 | ); |
| 70 | |
| 71 | std::list<int> l3{check2.begin(), check2.end()}; |
| 72 | test_eq( |
| 73 | "iterator range initialization", |
| 74 | check2.begin(), check2.end(), |
| 75 | l3.begin(), l3.end() |
| 76 | ); |
| 77 | |
| 78 | std::list<int> l4{l3}; |
| 79 | test_eq( |
| 80 | "copy initialization", |
| 81 | check2.begin(), check2.end(), |
| 82 | l4.begin(), l4.end() |
| 83 | ); |
| 84 | test_eq("size", l4.size(), 6U); |
| 85 | test_eq("not empty", l4.empty(), false); |
| 86 | |
| 87 | std::list<int> l5{std::move(l4)}; |
| 88 | test_eq( |
| 89 | "move initialization", |
| 90 | check2.begin(), check2.end(), |
| 91 | l5.begin(), l5.end() |
| 92 | ); |
| 93 | test_eq("move initializaiton - origin empty pt1", l4.empty(), true); |
| 94 | test_eq("move initializaiton - origin empty pt2", l4.size(), 0U); |
| 95 | |
| 96 | l4 = l5; |
| 97 | test_eq( |
| 98 | "copy assignment", |
| 99 | l5.begin(), l5.end(), |
| 100 | l4.begin(), l4.end() |
| 101 | ); |
| 102 | test_eq("copy assignment size", l4.size(), l5.size()); |
| 103 | |
| 104 | l1 = std::move(l4); |
| 105 | test_eq( |
| 106 | "move assignment", |
| 107 | l5.begin(), l5.end(), |
| 108 | l1.begin(), l1.end() |
| 109 | ); |