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

Method TestIterators

util/generic/string_ut.h:1081–1117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079 }
1080
1081 void TestIterators() {
1082 const char_type chars[] = {'f', 'o', 0};
1083
1084 TStringType str = chars;
1085 const TStringType constStr = str;
1086
1087 typename TStringType::const_iterator itBegin = str.begin();
1088 typename TStringType::const_iterator itEnd = str.end();
1089 typename TStringType::const_iterator citBegin = constStr.begin();
1090 typename TStringType::const_iterator citEnd = constStr.end();
1091
1092 UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'f');
1093 UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f');
1094
1095 str.front() = 'r';
1096 UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'r');
1097 UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f');
1098
1099 UNIT_ASSERT_VALUES_EQUAL(2, itEnd - itBegin);
1100 UNIT_ASSERT_VALUES_EQUAL(2, citEnd - citBegin);
1101
1102 UNIT_ASSERT_VALUES_EQUAL(*(++itBegin), (ui8)'o');
1103 UNIT_ASSERT_VALUES_EQUAL(*(++citBegin), (ui8)'o');
1104
1105 UNIT_ASSERT_VALUES_EQUAL(*(--itBegin), (ui8)'r');
1106 UNIT_ASSERT_VALUES_EQUAL(*(--citBegin), (ui8)'f');
1107
1108 UNIT_ASSERT_VALUES_EQUAL(*(itBegin++), (ui8)'r');
1109 UNIT_ASSERT_VALUES_EQUAL(*(citBegin++), (ui8)'f');
1110 UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'o');
1111 UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'o');
1112
1113 UNIT_ASSERT_VALUES_EQUAL(*(itBegin--), (ui8)'o');
1114 UNIT_ASSERT_VALUES_EQUAL(*(citBegin--), (ui8)'o');
1115 UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'r');
1116 UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f');
1117 }
1118
1119 void TestReverseIterators() {
1120 const char_type chars[] = {'f', 'o', 0};

Callers

nothing calls this directly

Calls 3

beginMethod · 0.45
endMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected