44
55namespace {
66
7+ // clang-format off
8+ using exceptionTestTypes = ::testing::Types<
9+ TestParam<Trivial, 0 >, TestParam<Trivial, 42 >,
10+ TestParam<NonTrivial, 0 >, TestParam<NonTrivial, 42 >>;
11+ // clang-format on
12+
713template <typename Param> class NoExceptions : public IVBasicTest <Param> {};
8- TYPED_TEST_SUITE (NoExceptions, IVAllTypes );
14+ TYPED_TEST_SUITE (NoExceptions, exceptionTestTypes );
915
1016TYPED_TEST (NoExceptions, NonThrowing) {
1117
1218 using IV = TestFixture::IV;
19+ using T = TestFixture::T;
1320
1421 const auto reference = this ->unique ();
1522
1623 IV device;
1724
1825 device.assign (reference.begin (), reference.end ());
1926 EXPECT_EQ (device, reference);
20- device.clear ();
27+
28+ EXPECT_EQ (device.try_emplace_back (T{}), nullptr );
29+ EXPECT_EQ (device.try_push_back (T{}), nullptr );
30+ auto range = std::array<T, 1 >{};
31+ EXPECT_EQ (device.try_append_range (range), range.begin ());
32+
33+ IV sanitycheck = this ->unique ();
34+ EXPECT_EQ (sanitycheck.size (), IV::capacity ());
2135}
2236
23- TYPED_TEST (NoExceptions, IVAllTypes ) {
37+ TYPED_TEST (NoExceptions, emplace_back ) {
2438
2539 using IV = TestFixture::IV;
2640 using T = TestFixture::T;
27-
28- IV sanitycheck = this ->unique ();
29- EXPECT_EQ (sanitycheck.size (), IV::capacity ());
41+ GTEST_FLAG_SET (death_test_style, " fast" );
3042
3143 EXPECT_DEATH (
3244 {
3345 IV device = this ->unique ();
3446 device.emplace_back (T{});
3547 },
3648 " .*" );
49+ }
50+
51+ TYPED_TEST (NoExceptions, resize) {
52+
53+ using IV = TestFixture::IV;
54+ using T = TestFixture::T;
55+ GTEST_FLAG_SET (death_test_style, " fast" );
3756
3857 EXPECT_DEATH (
3958 {
@@ -48,29 +67,50 @@ TYPED_TEST(NoExceptions, IVAllTypes) {
4867 device.resize (IV::capacity () + 1 , T{});
4968 },
5069 " .*" );
70+ }
71+
72+ TYPED_TEST (NoExceptions, reserve) {
73+
74+ using IV = TestFixture::IV;
75+ using T = TestFixture::T;
76+ GTEST_FLAG_SET (death_test_style, " fast" );
5177
5278 EXPECT_DEATH (
5379 {
5480 IV device = this ->unique ();
5581 device.reserve (IV::capacity () + 1 );
5682 },
5783 " .*" );
84+ }
85+
86+ TYPED_TEST (NoExceptions, append_range) {
87+
88+ using IV = TestFixture::IV;
89+ using T = TestFixture::T;
90+ GTEST_FLAG_SET (death_test_style, " fast" );
5891
5992 EXPECT_DEATH (
6093 {
6194 IV device{};
62- device.append_range (std::array<T, IV::capacity () + 2 >{});
95+ device.append_range (std::array<T, IV::capacity () + 1 >{});
6396 },
6497 " .*" );
6598
6699 EXPECT_DEATH (
67100 {
68101 IV device = this ->unique ();
69- device.append_range (std::array<T, 2 >{});
102+ device.append_range (std::array<T, 1 >{});
70103 },
71104 " .*" );
72105
73106 // TODO consider adding test for append_range of unsized range
107+ }
108+
109+ TYPED_TEST (NoExceptions, insert) {
110+
111+ using IV = TestFixture::IV;
112+ using T = TestFixture::T;
113+ GTEST_FLAG_SET (death_test_style, " fast" );
74114
75115 if constexpr (IV::capacity () > 0 ) {
76116 EXPECT_DEATH (
@@ -93,18 +133,25 @@ TYPED_TEST(NoExceptions, IVAllTypes) {
93133 device.insert (device.end (), range.begin (), range.end ());
94134 },
95135 " .*" );
136+ }
137+
138+ TYPED_TEST (NoExceptions, at) {
139+
140+ using IV = TestFixture::IV;
141+ using T = TestFixture::T;
142+ GTEST_FLAG_SET (death_test_style, " fast" );
96143
97144 EXPECT_DEATH (
98145 {
99146 IV device = this ->unique ();
100- auto e = device.at (IV::capacity () + 1 );
147+ auto e = device.at (IV::capacity ());
101148 },
102149 " .*" );
103150
104151 EXPECT_DEATH (
105152 {
106153 IV device;
107- const auto e = device.at (IV::capacity () + 1 );
154+ const auto e = device.at (IV::capacity ());
108155 },
109156 " .*" );
110157}
0 commit comments