MCPcopy Create free account
hub / github.com/boostorg/json / testCapacity

Method testCapacity

test/string.cpp:1289–1371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1287 }
1288
1289 void
1290 testCapacity()
1291 {
1292 test_vectors const t;
1293
1294 // empty()
1295 {
1296 {
1297 string s;
1298 BOOST_TEST(s.empty());
1299 }
1300 {
1301 string s = "abc";
1302 BOOST_TEST(! s.empty());
1303 }
1304 }
1305
1306 // size()
1307 // max_size()
1308 {
1309 string s = "abc";
1310 BOOST_TEST(s.size() == 3);
1311 BOOST_TEST(s.max_size() < string::npos);
1312 }
1313
1314 // reserve(size_type)
1315 {
1316 fail_loop([&](storage_ptr const& sp)
1317 {
1318 string s(sp);
1319 s.append(t.v1);
1320 s.append(t.v2);
1321
1322 s.reserve(0);
1323 BOOST_TEST(s.size() ==
1324 t.v1.size() + t.v2.size());
1325
1326 s.reserve(t.v1.size() + t.v2.size());
1327 BOOST_TEST(s.size() ==
1328 t.v1.size() + t.v2.size());
1329
1330 s.reserve(s.size() * 2);
1331 BOOST_TEST(s.capacity() >
1332 t.v1.size() + t.v2.size());
1333
1334 s.resize(t.v1.size());
1335 s.reserve(t.v1.size());
1336 BOOST_TEST(s == t.v1);
1337 });
1338 }
1339
1340 // capacity()
1341 {
1342 // implied
1343 }
1344
1345 // shrink_to_fit()
1346 fail_loop([&](storage_ptr const& sp)

Callers

nothing calls this directly

Calls 8

fail_loopFunction · 0.85
resizeMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
max_sizeMethod · 0.45
appendMethod · 0.45
reserveMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected