@@ -1166,6 +1166,27 @@ TYPED_TEST(Modifiers, Insert) {
11661166TYPED_TEST (Modifiers, PushBack) {
11671167 // constexpr reference push_back(const T& x);
11681168 // constexpr reference push_back(T&& x);
1169+ //
1170+ // Returns: back().
1171+ // Throws: bad_alloc or any exception thrown by the initialization of the
1172+ // inserted element.
1173+ // Complexity: Constant.
1174+ // Remarks: If an exception is thrown, there are no effects on *this.
1175+
1176+ using IV = TestFixture::IV;
1177+
1178+ const auto reference = this ->unique ();
1179+
1180+ IV device;
1181+ for (int i = 0 ; i < reference.size (); ++i) {
1182+ EXPECT_EQ (device.push_back (reference[i]), device.back ());
1183+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1184+ }
1185+ }
1186+
1187+ // TODO: Check if there's extra copies
1188+
1189+ TYPED_TEST (Modifiers, EmplaceBack) {
11691190 // template<class... Args>
11701191 // constexpr reference emplace_back(Args&&... args);
11711192 //
@@ -1175,11 +1196,18 @@ TYPED_TEST(Modifiers, PushBack) {
11751196 // Complexity: Constant.
11761197 // Remarks: If an exception is thrown, there are no effects on *this.
11771198
1178- // TODO
1179- GTEST_SKIP ();
1199+ using IV = TestFixture::IV;
1200+
1201+ const auto reference = this ->unique ();
1202+
1203+ IV device;
1204+ for (int i = 0 ; i < reference.size (); ++i) {
1205+ EXPECT_EQ (device.emplace_back (reference[i].value ), device.back ());
1206+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1207+ }
11801208}
11811209
1182- TYPED_TEST (Modifiers, TryPushBack ) {
1210+ TYPED_TEST (Modifiers, TryEmplaceBack ) {
11831211 // template<class... Args>
11841212 // constexpr pointer try_emplace_back(Args&&... args);
11851213 // constexpr pointer try_push_back(const T& x);
@@ -1201,8 +1229,113 @@ TYPED_TEST(Modifiers, TryPushBack) {
12011229 // Complexity: Constant.
12021230 // Remarks: If an exception is thrown, there are no effects on *this.
12031231
1204- // TODO
1205- GTEST_SKIP ();
1232+ using IV = TestFixture::IV;
1233+
1234+ const auto reference = this ->unique ();
1235+ IV device;
1236+ if (!reference.empty ()) {
1237+ for (int i = 0 ; i < reference.size (); ++i) {
1238+ EXPECT_EQ (device.try_emplace_back (reference[i].value ),
1239+ std::addressof (device.back ()));
1240+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1241+ }
1242+
1243+ EXPECT_EQ (device.try_emplace_back (reference[0 ].value ), nullptr );
1244+ EXPECT_EQ (device, reference);
1245+ } else {
1246+ EXPECT_EQ (device.try_emplace_back (0 ), nullptr );
1247+ EXPECT_EQ (device, IV ());
1248+ }
1249+ }
1250+
1251+ TYPED_TEST (Modifiers, TryPushBackConstRef) {
1252+ // template<class... Args>
1253+ // constexpr pointer try_emplace_back(Args&&... args);
1254+ // constexpr pointer try_push_back(const T& x);
1255+ // constexpr pointer try_push_back(T&& x);
1256+ //
1257+ // Let vals denote a pack:
1258+ // (8.1) std::forward<Args>(args)... for the first overload,
1259+ // (8.2) x for the second overload,
1260+ // (8.3) std::move(x) for the third overload.
1261+ //
1262+ // Preconditions: value_type is Cpp17EmplaceConstructible into inplace_vector
1263+ // from vals....
1264+ // Effects: If size() < capacity() is true, appends an object of type T
1265+ // direct-non-list-initialized with vals.... Otherwise, there are no effects.
1266+ // Returns: nullptr if size() == capacity() is true, otherwise
1267+ // addressof(back()).
1268+ // Throws: Nothing unless an exception is thrown by the initialization of the
1269+ // inserted element.
1270+ // Complexity: Constant.
1271+ // Remarks: If an exception is thrown, there are no effects on *this.
1272+
1273+ using IV = TestFixture::IV;
1274+ using T = TestFixture::T;
1275+
1276+ const auto reference = this ->unique ();
1277+ IV device;
1278+
1279+ if (!reference.empty ()) {
1280+ for (int i = 0 ; i < reference.size (); ++i) {
1281+ EXPECT_EQ (device.try_push_back (reference[i]),
1282+ std::addressof (device.back ()));
1283+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1284+ }
1285+
1286+ EXPECT_EQ (device.try_push_back (reference[0 ]), nullptr );
1287+ EXPECT_EQ (device, reference);
1288+ } else {
1289+ T val{0 };
1290+ EXPECT_EQ (device.try_push_back (val), nullptr );
1291+ EXPECT_EQ (device, IV ());
1292+ }
1293+ }
1294+
1295+ TYPED_TEST (Modifiers, TryPushBackRV) {
1296+ // template<class... Args>
1297+ // constexpr pointer try_emplace_back(Args&&... args);
1298+ // constexpr pointer try_push_back(const T& x);
1299+ // constexpr pointer try_push_back(T&& x);
1300+ //
1301+ // Let vals denote a pack:
1302+ // (8.1) std::forward<Args>(args)... for the first overload,
1303+ // (8.2) x for the second overload,
1304+ // (8.3) std::move(x) for the third overload.
1305+ //
1306+ // Preconditions: value_type is Cpp17EmplaceConstructible into inplace_vector
1307+ // from vals....
1308+ // Effects: If size() < capacity() is true, appends an object of type T
1309+ // direct-non-list-initialized with vals.... Otherwise, there are no effects.
1310+ // Returns: nullptr if size() == capacity() is true, otherwise
1311+ // addressof(back()).
1312+ // Throws: Nothing unless an exception is thrown by the initialization of the
1313+ // inserted element.
1314+ // Complexity: Constant.
1315+ // Remarks: If an exception is thrown, there are no effects on *this.
1316+
1317+ using IV = TestFixture::IV;
1318+ using T = TestFixture::T;
1319+
1320+ const auto reference = this ->unique ();
1321+
1322+ IV device;
1323+
1324+ if (!reference.empty ()) {
1325+ for (int i = 0 ; i < reference.size (); ++i) {
1326+ T val{reference[i].value };
1327+ EXPECT_EQ (device.try_push_back (std::move (val)),
1328+ std::addressof (device.back ()));
1329+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1330+ }
1331+
1332+ EXPECT_EQ (device.try_push_back (reference[0 ]), nullptr );
1333+ EXPECT_EQ (device, reference);
1334+ } else {
1335+ T val{0 };
1336+ EXPECT_EQ (device.try_push_back (std::move (val)), nullptr );
1337+ EXPECT_EQ (device, IV ());
1338+ }
12061339}
12071340
12081341TYPED_TEST (Modifiers, TryAppendRanges) {
@@ -1237,19 +1370,53 @@ TYPED_TEST(Modifiers, UncheckedEmplacedBack) {
12371370 // Effects: Equivalent to: return
12381371 // *try_emplace_back(std::forward<Args>(args)...);
12391372
1240- // TODO
1241- GTEST_SKIP ();
1373+ using IV = TestFixture::IV;
1374+
1375+ const auto reference = this ->unique ();
1376+
1377+ IV device;
1378+ for (int i = 0 ; i < reference.size (); ++i) {
1379+ EXPECT_EQ (device.unchecked_emplace_back (reference[i].value ), device.back ());
1380+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1381+ }
12421382}
12431383
1244- TYPED_TEST (Modifiers, UncheckedPushBack ) {
1384+ TYPED_TEST (Modifiers, UncheckedPushBackConstRef ) {
12451385 // constexpr reference unchecked_push_back(const T& x);
12461386 // constexpr reference unchecked_push_back(T&& x);
12471387 // Preconditions: size() < capacity() is true.
12481388 // Effects: Equivalent to: return
12491389 // *try_push_back(std::forward<decltype(x)>(x));
12501390
1251- // TODO
1252- GTEST_SKIP ();
1391+ using IV = TestFixture::IV;
1392+
1393+ const auto reference = this ->unique ();
1394+
1395+ IV device;
1396+ for (int i = 0 ; i < reference.size (); ++i) {
1397+ EXPECT_EQ (device.unchecked_push_back (reference[i]), device.back ());
1398+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1399+ }
1400+ }
1401+
1402+ TYPED_TEST (Modifiers, UncheckedPushBackRV) {
1403+ // constexpr reference unchecked_push_back(const T& x);
1404+ // constexpr reference unchecked_push_back(T&& x);
1405+ // Preconditions: size() < capacity() is true.
1406+ // Effects: Equivalent to: return
1407+ // *try_push_back(std::forward<decltype(x)>(x));
1408+
1409+ using IV = TestFixture::IV;
1410+ using T = TestFixture::T;
1411+
1412+ const auto reference = this ->unique ();
1413+
1414+ IV device;
1415+ for (int i = 0 ; i < reference.size (); ++i) {
1416+ T val{reference[i].value };
1417+ EXPECT_EQ (device.unchecked_push_back (std::move (val)), device.back ());
1418+ EXPECT_EQ (device, IV (reference.begin (), reference.begin () + i + 1 ));
1419+ }
12531420}
12541421
12551422TYPED_TEST (Modifiers, ReserveNonEmpty) {
@@ -1260,7 +1427,7 @@ TYPED_TEST(Modifiers, ReserveNonEmpty) {
12601427
12611428 using IV = TestFixture::IV;
12621429
1263- auto reference = this ->unique ();
1430+ const auto reference = this ->unique ();
12641431
12651432 IV device (reference);
12661433
0 commit comments