@@ -1265,12 +1265,54 @@ TYPED_TEST(Modifiers, ReserveShrink) {
12651265 GTEST_SKIP ();
12661266}
12671267
1268- TYPED_TEST (Modifiers, Erase ) {
1268+ TYPED_TEST (Modifiers, EraseSingle ) {
12691269 // constexpr iterator erase(const_iterator position);
12701270 // constexpr iterator erase(const_iterator first, const_iterator last);
12711271 // constexpr void pop_back();
12721272 //
12731273 // Effects: Invalidates iterators and references at or after the point of the
1274+ // erase.Single
1275+ // Throws: Nothing unless an exception is thrown by the assignment
1276+ // operator or move assignment operator of T.
1277+ // Complexity: The destructor of T is called the number of times equal to the
1278+ // number of the elements erased, but the assignment operator of T is called
1279+ // the number of times equal to the number of elements after the erased
1280+ // elements.
1281+
1282+ auto device = this ->unique ();
1283+
1284+ if (device.empty ())
1285+ return ;
1286+
1287+ auto itr = device.erase (device.begin ());
1288+ if (device.empty ())
1289+ return ;
1290+
1291+ EXPECT_EQ (itr, device.begin ());
1292+
1293+ auto last_itr = device.end ();
1294+ last_itr = --last_itr;
1295+
1296+ itr = device.erase (last_itr);
1297+ EXPECT_EQ (itr, device.end ());
1298+
1299+ auto mid_idx = device.size () / 2 ;
1300+ auto mid_itr = device.begin () + mid_idx;
1301+ itr = device.erase (mid_itr);
1302+ EXPECT_EQ (itr, device.begin () + mid_idx);
1303+
1304+ auto size = device.size ();
1305+ for (auto i = 0 ; i < size; ++i)
1306+ device.erase (device.begin ());
1307+
1308+ EXPECT_TRUE (device.empty ())
1309+ << " device still have " << device.size () << " elements" ;
1310+ }
1311+
1312+ TYPED_TEST (Modifiers, EraseRange) {
1313+ // constexpr iterator erase(const_iterator first, const_iterator last);
1314+ //
1315+ // Effects: Invalidates iterators and references at or after the point of the
12741316 // erase.
12751317 // Throws: Nothing unless an exception is thrown by the assignment
12761318 // operator or move assignment operator of T.
@@ -1283,6 +1325,34 @@ TYPED_TEST(Modifiers, Erase) {
12831325 GTEST_SKIP ();
12841326}
12851327
1328+ TYPED_TEST (Modifiers, PopBack) {
1329+ // constexpr void pop_back();
1330+ //
1331+ // Effects: Invalidates iterators and references at or after the point of the
1332+ // erase.
1333+ // Throws: Nothing unless an exception is thrown by the assignment
1334+ // operator or move assignment operator of T.
1335+ // Complexity: The destructor of T is called the number of times equal to the
1336+ // number of the elements erased, but the assignment operator of T is called
1337+ // the number of times equal to the number of elements after the erased
1338+ // elements.
1339+
1340+ using IV = TestFixture::IV;
1341+
1342+ auto reference = this ->unique ();
1343+ IV device (reference);
1344+
1345+ if (reference.capacity () == 0 )
1346+ return ;
1347+
1348+ for (auto i = int (reference.size ()); i >= 0 ; --i) {
1349+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i));
1350+ device.pop_back ();
1351+ }
1352+
1353+ EXPECT_TRUE (device.size ());
1354+ }
1355+
12861356// 23.3.14.6 Erasure [inplace.vector.erasure]
12871357
12881358template <typename Param> class Erasure : public BasicTest <Param> {};
0 commit comments