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

Method testInsert

test/string.cpp:1398–1733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1396 }
1397
1398 void
1399 testInsert()
1400 {
1401 test_vectors const t;
1402
1403 // insert(size_type, size_type, char)
1404 {
1405 fail_loop([&](storage_ptr const& sp)
1406 {
1407 string s(t.v1, sp);
1408 s.insert(1, 3, '*');
1409 BOOST_TEST(s == std::string(
1410 t.v1).insert(1, 3, '*'));
1411 });
1412
1413 fail_loop([&](storage_ptr const& sp)
1414 {
1415 string s(t.v2, sp);
1416 s.insert(1, 3, '*');
1417 BOOST_TEST(s == std::string(
1418 t.v2).insert(1, 3, '*'));
1419 });
1420
1421 // pos out of range
1422 {
1423 string s(t.v1);
1424 BOOST_TEST_THROWS_WITH_LOCATION(
1425 (s.insert(s.size() + 2, 1, '*')) );
1426 }
1427
1428 // size > max_size
1429 {
1430 string s(t.v1);
1431 BOOST_TEST_THROWS_WITH_LOCATION(
1432 s.insert(1, s.max_size(), 'a') );
1433 }
1434 }
1435
1436 // insert(size_type, char const*)
1437 {
1438 fail_loop([&](storage_ptr const& sp)
1439 {
1440 string s(t.v1, sp);
1441 s.insert(1, "***");
1442 BOOST_TEST(s == std::string(
1443 t.v1).insert(1, "***"));
1444 });
1445
1446 fail_loop([&](storage_ptr const& sp)
1447 {
1448 string s(t.v2, sp);
1449 s.insert(1, "***");
1450 BOOST_TEST(s == std::string(
1451 t.v2).insert(1, "***"));
1452 });
1453
1454 // pos out of range
1455 {

Callers

nothing calls this directly

Calls 13

fail_loopFunction · 0.85
string_viewClass · 0.85
make_input_iteratorFunction · 0.85
subviewMethod · 0.80
stringClass · 0.50
insertMethod · 0.45
sizeMethod · 0.45
max_sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
reserveMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected