本文整理汇总了C++中BidiCharacterRun::reversed方法的典型用法代码示例。如果您正苦于以下问题:C++ BidiCharacterRun::reversed方法的具体用法?C++ BidiCharacterRun::reversed怎么用?C++ BidiCharacterRun::reversed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BidiCharacterRun
的用法示例。
在下文中一共展示了BidiCharacterRun::reversed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
void BidiTestRunner::runTest(const std::basic_string<UChar>& input, const std::vector<int>& expectedOrder,
const std::vector<int>& expectedLevels, bidi_test::ParagraphDirection paragraphDirection,
const std::string& line, size_t lineNumber)
{
if (!m_skippedCodePoints.empty()) {
for (size_t i = 0; i < input.size(); i++) {
if (m_skippedCodePoints.count(input[i])) {
m_testsSkipped++;
return;
}
}
}
m_testsRun++;
TextRun textRun(input.data(), input.size());
switch (paragraphDirection) {
case bidi_test::DirectionAutoLTR:
textRun.setDirection(determineParagraphDirectionality(textRun));
break;
case bidi_test::DirectionLTR:
textRun.setDirection(LTR);
break;
case bidi_test::DirectionRTL:
textRun.setDirection(RTL);
break;
}
BidiResolver<TextRunIterator, BidiCharacterRun> resolver;
resolver.setStatus(BidiStatus(textRun.direction(), textRun.directionalOverride()));
resolver.setPositionIgnoringNestedIsolates(TextRunIterator(&textRun, 0));
BidiRunList<BidiCharacterRun>& runs = resolver.runs();
resolver.createBidiRunsForLine(TextRunIterator(&textRun, textRun.length()));
std::ostringstream errorContext;
errorContext << ", line " << lineNumber << " \"" << line << "\"";
errorContext << " context: " << bidi_test::nameFromParagraphDirection(paragraphDirection);
std::vector<int> actualOrder;
std::vector<int> actualLevels;
actualLevels.assign(input.size(), -1);
BidiCharacterRun* run = runs.firstRun();
while (run) {
// Blink's UBA just makes runs, the actual ordering of the display of characters
// is handled later in our pipeline, so we fake it here:
bool reversed = run->reversed(false);
ASSERT(run->stop() >= run->start());
size_t length = run->stop() - run->start();
for (size_t i = 0; i < length; i++) {
int inputIndex = reversed ? run->stop() - i - 1 : run->start() + i;
if (!isNonRenderedCodePoint(input[inputIndex]))
actualOrder.push_back(inputIndex);
// BidiTest.txt gives expected level data in the order of the original input.
actualLevels[inputIndex] = run->level();
}
run = run->next();
}
if (expectedOrder.size() != actualOrder.size()) {
m_ignoredCharFailures++;
EXPECT_EQ(expectedOrder.size(), actualOrder.size()) << errorContext.str();
} else if (expectedOrder != actualOrder) {
m_orderFailures++;
printf("ORDER %s%s\n", diffString(actualOrder, expectedOrder).c_str(), errorContext.str().c_str());
}
if (expectedLevels.size() != actualLevels.size()) {
m_ignoredCharFailures++;
EXPECT_EQ(expectedLevels.size(), actualLevels.size()) << errorContext.str();
} else {
for (size_t i = 0; i < expectedLevels.size(); i++) {
// level == -1 means the level should be ignored.
if (expectedLevels[i] == actualLevels[i] || expectedLevels[i] == -1)
continue;
printf("LEVELS %s%s\n", diffString(actualLevels, expectedLevels).c_str(), errorContext.str().c_str());
m_levelFailures++;
break;
}
}
runs.deleteRuns();
}