MCPcopy Create free account
hub / github.com/catboost/catboost / TestReplace

Method TestReplace

util/generic/string_ut.h:570–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568 }
569
570 void TestReplace() {
571 TStringType s(Data._0123456());
572 UNIT_ASSERT(s.copy() == Data._0123456());
573
574 // append family
575 s.append(Data.x());
576 UNIT_ASSERT(s == Data._0123456x());
577
578#ifdef TSTRING_IS_STD_STRING
579 s.append(Data.xyz() + 1, 1);
580#else
581 s.append(Data.xyz(), 1, 1);
582#endif
583 UNIT_ASSERT(s == Data._0123456xy());
584
585 s.append(TStringType(Data.z()));
586 UNIT_ASSERT(s == Data._0123456xyz());
587
588 s.append(TStringType(Data.XYZ()), 2, 1);
589 UNIT_ASSERT(s == Data._0123456xyzZ());
590
591 s.append(*Data._0());
592 UNIT_ASSERT(s == Data._0123456xyzZ0());
593
594 // prepend family
595 s = Data._0123456xyz();
596 s.prepend(TStringType(Data.abc()));
597 UNIT_ASSERT(s == Data.abc0123456xyz());
598
599 s.prepend(TStringType(Data.ABC()), 1, 2);
600 UNIT_ASSERT(s == Data.BCabc0123456xyz());
601
602 s.prepend(Data.qwe());
603 UNIT_ASSERT(s == Data.qweBCabc0123456xyz());
604
605 s.prepend(*Data._1());
606 UNIT_ASSERT(s == Data._1qweBCabc0123456xyz());
607
608 // substr
609 s = Data.abc0123456xyz();
610 s = s.substr(3, 7);
611 UNIT_ASSERT(s == Data._0123456());
612
613 // insert family
614 s.insert(2, Data.abc());
615 UNIT_ASSERT(s == Data._01abc23456());
616
617 s.insert(2, TStringType(Data.ABC()));
618 UNIT_ASSERT(s == Data._01ABCabc23456());
619
620 s.insert(0, TStringType(Data.QWE()), 1, 1);
621 UNIT_ASSERT(s == Data.W01ABCabc23456());
622
623 // replace family
624 s = Data._01abc23456();
625 s.replace(0, 7, Data.abcd());
626 UNIT_ASSERT(s == Data.abcd456());
627

Callers

nothing calls this directly

Calls 15

_0123456Method · 0.80
_0123456xMethod · 0.80
xyzMethod · 0.80
_0123456xyMethod · 0.80
_0123456xyzMethod · 0.80
XYZMethod · 0.80
_0123456xyzZMethod · 0.80
_0Method · 0.80
_0123456xyzZ0Method · 0.80
abcMethod · 0.80
abc0123456xyzMethod · 0.80
ABCMethod · 0.80

Tested by

no test coverage detected