| 1117 | } |
| 1118 | |
| 1119 | void TestReverseIterators() { |
| 1120 | const char_type chars[] = {'f', 'o', 0}; |
| 1121 | |
| 1122 | TStringType str = chars; |
| 1123 | const TStringType constStr = str; |
| 1124 | |
| 1125 | typename TStringType::reverse_iterator ritBegin = str.rbegin(); |
| 1126 | typename TStringType::reverse_iterator ritEnd = str.rend(); |
| 1127 | typename TStringType::const_reverse_iterator critBegin = constStr.rbegin(); |
| 1128 | typename TStringType::const_reverse_iterator critEnd = constStr.rend(); |
| 1129 | |
| 1130 | UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'o'); |
| 1131 | UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); |
| 1132 | |
| 1133 | str.back() = (ui8)'r'; |
| 1134 | UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'r'); |
| 1135 | UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); |
| 1136 | |
| 1137 | UNIT_ASSERT_VALUES_EQUAL(2, ritEnd - ritBegin); |
| 1138 | UNIT_ASSERT_VALUES_EQUAL(2, critEnd - critBegin); |
| 1139 | |
| 1140 | UNIT_ASSERT_VALUES_EQUAL(*(++ritBegin), (ui8)'f'); |
| 1141 | UNIT_ASSERT_VALUES_EQUAL(*(++critBegin), (ui8)'f'); |
| 1142 | |
| 1143 | UNIT_ASSERT_VALUES_EQUAL(*(--ritBegin), (ui8)'r'); |
| 1144 | UNIT_ASSERT_VALUES_EQUAL(*(--critBegin), (ui8)'o'); |
| 1145 | |
| 1146 | UNIT_ASSERT_VALUES_EQUAL(*(ritBegin++), (ui8)'r'); |
| 1147 | UNIT_ASSERT_VALUES_EQUAL(*(critBegin++), (ui8)'o'); |
| 1148 | UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'f'); |
| 1149 | UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'f'); |
| 1150 | |
| 1151 | UNIT_ASSERT_VALUES_EQUAL(*(ritBegin--), (ui8)'f'); |
| 1152 | UNIT_ASSERT_VALUES_EQUAL(*(critBegin--), (ui8)'f'); |
| 1153 | UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'r'); |
| 1154 | UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); |
| 1155 | |
| 1156 | *ritBegin = (ui8)'e'; |
| 1157 | UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'e'); |
| 1158 | |
| 1159 | str = chars; |
| 1160 | auto it = std::find_if( |
| 1161 | str.rbegin(), str.rend(), |
| 1162 | [](char_type c) { return c == 'o'; }); |
| 1163 | UNIT_ASSERT_EQUAL(it, str.rbegin()); |
| 1164 | } |
| 1165 | }; |