Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: third_party/WebKit/Source/platform/text/BidiTestHarness.h

Issue 2879903002: blink style: Update BidiTestHarness (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/text/BidiResolverTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Both of those are too tied to their respective projects to be use to Blink. 51 // Both of those are too tied to their respective projects to be use to Blink.
52 52
53 // There are non-C implmentations to parse BidiTest.txt as well, including: 53 // There are non-C implmentations to parse BidiTest.txt as well, including:
54 // https://github.com/twitter/twitter-cldr-rb/blob/master/spec/bidi/bidi_spec.rb 54 // https://github.com/twitter/twitter-cldr-rb/blob/master/spec/bidi/bidi_spec.rb
55 55
56 // NOTE: None of this file is currently written to be thread-safe. 56 // NOTE: None of this file is currently written to be thread-safe.
57 57
58 namespace bidi_test { 58 namespace bidi_test {
59 59
60 enum ParagraphDirection { 60 enum ParagraphDirection {
61 DirectionNone = 0, 61 kDirectionNone = 0,
62 DirectionAutoLTR = 1, 62 kDirectionAutoLTR = 1,
63 DirectionLTR = 2, 63 kDirectionLTR = 2,
64 DirectionRTL = 4, 64 kDirectionRTL = 4,
65 }; 65 };
66 const int kMaxParagraphDirection = 66 const int kMaxParagraphDirection =
67 DirectionAutoLTR | DirectionLTR | DirectionRTL; 67 kDirectionAutoLTR | kDirectionLTR | kDirectionRTL;
68 68
69 // For error printing: 69 // For error printing:
70 std::string nameFromParagraphDirection(ParagraphDirection paragraphDirection) { 70 std::string NameFromParagraphDirection(ParagraphDirection paragraph_direction) {
71 switch (paragraphDirection) { 71 switch (paragraph_direction) {
72 case bidi_test::DirectionAutoLTR: 72 case bidi_test::kDirectionAutoLTR:
73 return "Auto-LTR"; 73 return "Auto-LTR";
74 case bidi_test::DirectionLTR: 74 case bidi_test::kDirectionLTR:
75 return "LTR"; 75 return "LTR";
76 case bidi_test::DirectionRTL: 76 case bidi_test::kDirectionRTL:
77 return "RTL"; 77 return "RTL";
78 default: 78 default:
79 // This should never be reached. 79 // This should never be reached.
80 return ""; 80 return "";
81 } 81 }
82 } 82 }
83 83
84 template <class Runner> 84 template <class Runner>
85 class Harness { 85 class Harness {
86 public: 86 public:
87 Harness(Runner& runner) : m_runner(runner) {} 87 Harness(Runner& runner) : runner_(runner) {}
88 void parse(std::istream& bidiTestFile); 88 void Parse(std::istream& bidi_test_file);
89 89
90 private: 90 private:
91 Runner& m_runner; 91 Runner& runner_;
92 }; 92 };
93 93
94 // We could use boost::trim, but no other part of Blink uses boost yet. 94 // We could use boost::trim, but no other part of Blink uses boost yet.
95 inline void ltrim(std::string& s) { 95 inline void Ltrim(std::string& s) {
96 static const std::string separators(" \t"); 96 static const std::string kSeparators(" \t");
97 s.erase(0, s.find_first_not_of(separators)); 97 s.erase(0, s.find_first_not_of(kSeparators));
98 } 98 }
99 99
100 inline void rtrim(std::string& s) { 100 inline void Rtrim(std::string& s) {
101 static const std::string separators(" \t"); 101 static const std::string kSeparators(" \t");
102 size_t lastNonSpace = s.find_last_not_of(separators); 102 size_t last_non_space = s.find_last_not_of(kSeparators);
103 if (lastNonSpace == std::string::npos) { 103 if (last_non_space == std::string::npos) {
104 s.erase(); 104 s.erase();
105 return; 105 return;
106 } 106 }
107 size_t firstSpaceAtEndOfString = lastNonSpace + 1; 107 size_t first_space_at_end_of_string = last_non_space + 1;
108 if (firstSpaceAtEndOfString >= s.size()) 108 if (first_space_at_end_of_string >= s.size())
109 return; // lastNonSpace was the last char. 109 return; // lastNonSpace was the last char.
110 s.erase(firstSpaceAtEndOfString, 110 s.erase(first_space_at_end_of_string,
111 std::string::npos); // erase to the end of the string. 111 std::string::npos); // erase to the end of the string.
112 } 112 }
113 113
114 inline void trim(std::string& s) { 114 inline void Trim(std::string& s) {
115 rtrim(s); 115 Rtrim(s);
116 ltrim(s); 116 Ltrim(s);
117 } 117 }
118 118
119 static std::vector<std::string> parseStringList(const std::string& str) { 119 static std::vector<std::string> ParseStringList(const std::string& str) {
120 std::vector<std::string> strings; 120 std::vector<std::string> strings;
121 static const std::string separators(" \t"); 121 static const std::string kSeparators(" \t");
122 size_t lastPos = str.find_first_not_of(separators); // skip leading spaces 122 size_t last_pos = str.find_first_not_of(kSeparators); // skip leading spaces
123 size_t pos = str.find_first_of(separators, lastPos); // find next space 123 size_t pos = str.find_first_of(kSeparators, last_pos); // find next space
124 124
125 while (std::string::npos != pos || std::string::npos != lastPos) { 125 while (std::string::npos != pos || std::string::npos != last_pos) {
126 strings.push_back(str.substr(lastPos, pos - lastPos)); 126 strings.push_back(str.substr(last_pos, pos - last_pos));
127 lastPos = str.find_first_not_of(separators, pos); 127 last_pos = str.find_first_not_of(kSeparators, pos);
128 pos = str.find_first_of(separators, lastPos); 128 pos = str.find_first_of(kSeparators, last_pos);
129 } 129 }
130 return strings; 130 return strings;
131 } 131 }
132 132
133 static int parseInt(const std::string& str) { 133 static int ParseInt(const std::string& str) {
134 return atoi(str.c_str()); 134 return atoi(str.c_str());
135 } 135 }
136 136
137 static std::vector<int> parseIntList(const std::string& str) { 137 static std::vector<int> ParseIntList(const std::string& str) {
138 std::vector<int> ints; 138 std::vector<int> ints;
139 std::vector<std::string> strings = parseStringList(str); 139 std::vector<std::string> strings = ParseStringList(str);
140 for (size_t x = 0; x < strings.size(); x++) { 140 for (size_t x = 0; x < strings.size(); x++) {
141 int i = parseInt(strings[x]); 141 int i = ParseInt(strings[x]);
142 ints.push_back(i); 142 ints.push_back(i);
143 } 143 }
144 return ints; 144 return ints;
145 } 145 }
146 146
147 static std::vector<int> parseLevels(const std::string& line) { 147 static std::vector<int> ParseLevels(const std::string& line) {
148 std::vector<int> levels; 148 std::vector<int> levels;
149 std::vector<std::string> strings = parseStringList(line); 149 std::vector<std::string> strings = ParseStringList(line);
150 for (size_t x = 0; x < strings.size(); x++) { 150 for (size_t x = 0; x < strings.size(); x++) {
151 const std::string& levelString = strings[x]; 151 const std::string& level_string = strings[x];
152 int i; 152 int i;
153 if (levelString == "x") 153 if (level_string == "x")
154 i = -1; 154 i = -1;
155 else 155 else
156 i = parseInt(levelString); 156 i = ParseInt(level_string);
157 levels.push_back(i); 157 levels.push_back(i);
158 } 158 }
159 return levels; 159 return levels;
160 } 160 }
161 161
162 // This is not thread-safe as written. 162 // This is not thread-safe as written.
163 static std::basic_string<UChar> parseTestString(const std::string& line) { 163 static std::basic_string<UChar> ParseTestString(const std::string& line) {
164 std::basic_string<UChar> testString; 164 std::basic_string<UChar> test_string;
165 static std::map<std::string, UChar> charClassExamples; 165 static std::map<std::string, UChar> char_class_examples;
166 if (charClassExamples.empty()) { 166 if (char_class_examples.empty()) {
167 // FIXME: Explicit make_pair is ugly, but required for C++98 compat. 167 // FIXME: Explicit make_pair is ugly, but required for C++98 compat.
168 charClassExamples.insert(std::make_pair("L", 0x6c)); // 'l' for L 168 char_class_examples.insert(std::make_pair("L", 0x6c)); // 'l' for L
169 charClassExamples.insert(std::make_pair("R", 0x05D0)); // HEBREW ALEF 169 char_class_examples.insert(std::make_pair("R", 0x05D0)); // HEBREW ALEF
170 charClassExamples.insert(std::make_pair("EN", 0x33)); // '3' for EN 170 char_class_examples.insert(std::make_pair("EN", 0x33)); // '3' for EN
171 charClassExamples.insert(std::make_pair("ES", 0x2d)); // '-' for ES 171 char_class_examples.insert(std::make_pair("ES", 0x2d)); // '-' for ES
172 charClassExamples.insert(std::make_pair("ET", 0x25)); // '%' for ET 172 char_class_examples.insert(std::make_pair("ET", 0x25)); // '%' for ET
173 charClassExamples.insert(std::make_pair("AN", 0x0660)); // arabic 0 173 char_class_examples.insert(std::make_pair("AN", 0x0660)); // arabic 0
174 charClassExamples.insert(std::make_pair("CS", 0x2c)); // ',' for CS 174 char_class_examples.insert(std::make_pair("CS", 0x2c)); // ',' for CS
175 charClassExamples.insert(std::make_pair("B", 0x0A)); // <control-000A> 175 char_class_examples.insert(std::make_pair("B", 0x0A)); // <control-000A>
176 charClassExamples.insert(std::make_pair("S", 0x09)); // <control-0009> 176 char_class_examples.insert(std::make_pair("S", 0x09)); // <control-0009>
177 charClassExamples.insert(std::make_pair("WS", 0x20)); // ' ' for WS 177 char_class_examples.insert(std::make_pair("WS", 0x20)); // ' ' for WS
178 charClassExamples.insert(std::make_pair("ON", 0x3d)); // '=' for ON 178 char_class_examples.insert(std::make_pair("ON", 0x3d)); // '=' for ON
179 charClassExamples.insert( 179 char_class_examples.insert(
180 std::make_pair("NSM", 0x05BF)); // HEBREW POINT RAFE 180 std::make_pair("NSM", 0x05BF)); // HEBREW POINT RAFE
181 charClassExamples.insert(std::make_pair("AL", 0x0608)); // ARABIC RAY 181 char_class_examples.insert(std::make_pair("AL", 0x0608)); // ARABIC RAY
182 charClassExamples.insert(std::make_pair("BN", 0x00AD)); // SOFT HYPHEN 182 char_class_examples.insert(std::make_pair("BN", 0x00AD)); // SOFT HYPHEN
183 charClassExamples.insert(std::make_pair("LRE", 0x202A)); 183 char_class_examples.insert(std::make_pair("LRE", 0x202A));
184 charClassExamples.insert(std::make_pair("RLE", 0x202B)); 184 char_class_examples.insert(std::make_pair("RLE", 0x202B));
185 charClassExamples.insert(std::make_pair("PDF", 0x202C)); 185 char_class_examples.insert(std::make_pair("PDF", 0x202C));
186 charClassExamples.insert(std::make_pair("LRO", 0x202D)); 186 char_class_examples.insert(std::make_pair("LRO", 0x202D));
187 charClassExamples.insert(std::make_pair("RLO", 0x202E)); 187 char_class_examples.insert(std::make_pair("RLO", 0x202E));
188 charClassExamples.insert(std::make_pair("LRI", 0x2066)); 188 char_class_examples.insert(std::make_pair("LRI", 0x2066));
189 charClassExamples.insert(std::make_pair("RLI", 0x2067)); 189 char_class_examples.insert(std::make_pair("RLI", 0x2067));
190 charClassExamples.insert(std::make_pair("FSI", 0x2068)); 190 char_class_examples.insert(std::make_pair("FSI", 0x2068));
191 charClassExamples.insert(std::make_pair("PDI", 0x2069)); 191 char_class_examples.insert(std::make_pair("PDI", 0x2069));
192 } 192 }
193 193
194 std::vector<std::string> charClasses = parseStringList(line); 194 std::vector<std::string> char_classes = ParseStringList(line);
195 for (size_t i = 0; i < charClasses.size(); i++) { 195 for (size_t i = 0; i < char_classes.size(); i++) {
196 // FIXME: If the lookup failed we could return false for a parse error. 196 // FIXME: If the lookup failed we could return false for a parse error.
197 testString.push_back(charClassExamples.find(charClasses[i])->second); 197 test_string.push_back(char_class_examples.find(char_classes[i])->second);
198 } 198 }
199 return testString; 199 return test_string;
200 } 200 }
201 201
202 static bool parseParagraphDirectionMask(const std::string& line, 202 static bool ParseParagraphDirectionMask(const std::string& line,
203 int& modeMask) { 203 int& mode_mask) {
204 modeMask = parseInt(line); 204 mode_mask = ParseInt(line);
205 return modeMask >= 1 && modeMask <= kMaxParagraphDirection; 205 return mode_mask >= 1 && mode_mask <= kMaxParagraphDirection;
206 } 206 }
207 207
208 static void parseError(const std::string& line, size_t lineNumber) { 208 static void ParseError(const std::string& line, size_t line_number) {
209 // Use printf to avoid the expense of std::cout. 209 // Use printf to avoid the expense of std::cout.
210 printf("Parse error, line %zu : %s\n", lineNumber, line.c_str()); 210 printf("Parse error, line %zu : %s\n", line_number, line.c_str());
211 } 211 }
212 212
213 template <class Runner> 213 template <class Runner>
214 void Harness<Runner>::parse(std::istream& bidiTestFile) { 214 void Harness<Runner>::Parse(std::istream& bidi_test_file) {
215 static const std::string levelsPrefix("@Levels"); 215 static const std::string kLevelsPrefix("@Levels");
216 static const std::string reorderPrefix("@Reorder"); 216 static const std::string kReorderPrefix("@Reorder");
217 217
218 // FIXME: UChar is an ICU type and cheating a bit to use here. 218 // FIXME: UChar is an ICU type and cheating a bit to use here.
219 // uint16_t might be more portable. 219 // uint16_t might be more portable.
220 std::basic_string<UChar> testString; 220 std::basic_string<UChar> test_string;
221 std::vector<int> levels; 221 std::vector<int> levels;
222 std::vector<int> reorder; 222 std::vector<int> reorder;
223 int paragraphDirectionMask; 223 int paragraph_direction_mask;
224 224
225 std::string line; 225 std::string line;
226 size_t lineNumber = 0; 226 size_t line_number = 0;
227 while (std::getline(bidiTestFile, line)) { 227 while (std::getline(bidi_test_file, line)) {
228 lineNumber++; 228 line_number++;
229 const std::string originalLine = line; 229 const std::string original_line = line;
230 size_t commentStart = line.find_first_of('#'); 230 size_t comment_start = line.find_first_of('#');
231 if (commentStart != std::string::npos) 231 if (comment_start != std::string::npos)
232 line = line.substr(0, commentStart); 232 line = line.substr(0, comment_start);
233 trim(line); 233 Trim(line);
234 if (line.empty()) 234 if (line.empty())
235 continue; 235 continue;
236 if (line[0] == '@') { 236 if (line[0] == '@') {
237 if (!line.find(levelsPrefix)) { 237 if (!line.find(kLevelsPrefix)) {
238 levels = parseLevels(line.substr(levelsPrefix.length() + 1)); 238 levels = ParseLevels(line.substr(kLevelsPrefix.length() + 1));
239 continue; 239 continue;
240 } 240 }
241 if (!line.find(reorderPrefix)) { 241 if (!line.find(kReorderPrefix)) {
242 reorder = parseIntList(line.substr(reorderPrefix.length() + 1)); 242 reorder = ParseIntList(line.substr(kReorderPrefix.length() + 1));
243 continue; 243 continue;
244 } 244 }
245 } else { 245 } else {
246 // Assume it's a data line. 246 // Assume it's a data line.
247 size_t seperatorIndex = line.find_first_of(';'); 247 size_t seperator_index = line.find_first_of(';');
248 if (seperatorIndex == std::string::npos) { 248 if (seperator_index == std::string::npos) {
249 parseError(originalLine, lineNumber); 249 ParseError(original_line, line_number);
250 continue; 250 continue;
251 } 251 }
252 testString = parseTestString(line.substr(0, seperatorIndex)); 252 test_string = ParseTestString(line.substr(0, seperator_index));
253 if (!parseParagraphDirectionMask(line.substr(seperatorIndex + 1), 253 if (!ParseParagraphDirectionMask(line.substr(seperator_index + 1),
254 paragraphDirectionMask)) { 254 paragraph_direction_mask)) {
255 parseError(originalLine, lineNumber); 255 ParseError(original_line, line_number);
256 continue; 256 continue;
257 } 257 }
258 258
259 if (paragraphDirectionMask & DirectionAutoLTR) 259 if (paragraph_direction_mask & kDirectionAutoLTR) {
260 m_runner.RunTest(testString, reorder, levels, DirectionAutoLTR, 260 runner_.RunTest(test_string, reorder, levels, kDirectionAutoLTR,
261 originalLine, lineNumber); 261 original_line, line_number);
262 if (paragraphDirectionMask & DirectionLTR) 262 }
263 m_runner.RunTest(testString, reorder, levels, DirectionLTR, 263 if (paragraph_direction_mask & kDirectionLTR) {
264 originalLine, lineNumber); 264 runner_.RunTest(test_string, reorder, levels, kDirectionLTR,
265 if (paragraphDirectionMask & DirectionRTL) 265 original_line, line_number);
266 m_runner.RunTest(testString, reorder, levels, DirectionRTL, 266 }
267 originalLine, lineNumber); 267 if (paragraph_direction_mask & kDirectionRTL) {
268 runner_.RunTest(test_string, reorder, levels, kDirectionRTL,
269 original_line, line_number);
270 }
268 } 271 }
269 } 272 }
270 } 273 }
271 274
272 template <class Runner> 275 template <class Runner>
273 class CharacterHarness { 276 class CharacterHarness {
274 public: 277 public:
275 CharacterHarness(Runner& runner) : m_runner(runner) {} 278 CharacterHarness(Runner& runner) : runner_(runner) {}
276 void parse(std::istream& bidiTestFile); 279 void Parse(std::istream& bidi_test_file);
277 280
278 private: 281 private:
279 Runner& m_runner; 282 Runner& runner_;
280 }; 283 };
281 284
282 static std::basic_string<UChar> parseUCharHexadecimalList( 285 static std::basic_string<UChar> ParseUCharHexadecimalList(
283 const std::string& str) { 286 const std::string& str) {
284 std::basic_string<UChar> string; 287 std::basic_string<UChar> string;
285 std::vector<std::string> strings = parseStringList(str); 288 std::vector<std::string> strings = ParseStringList(str);
286 for (size_t x = 0; x < strings.size(); x++) { 289 for (size_t x = 0; x < strings.size(); x++) {
287 int i = strtol(strings[x].c_str(), nullptr, 16); 290 int i = strtol(strings[x].c_str(), nullptr, 16);
288 string.push_back((UChar)i); 291 string.push_back((UChar)i);
289 } 292 }
290 return string; 293 return string;
291 } 294 }
292 295
293 static ParagraphDirection parseParagraphDirection(const std::string& str) { 296 static ParagraphDirection ParseParagraphDirection(const std::string& str) {
294 int i = parseInt(str); 297 int i = ParseInt(str);
295 switch (i) { 298 switch (i) {
296 case 0: 299 case 0:
297 return DirectionLTR; 300 return kDirectionLTR;
298 case 1: 301 case 1:
299 return DirectionRTL; 302 return kDirectionRTL;
300 case 2: 303 case 2:
301 return DirectionAutoLTR; 304 return kDirectionAutoLTR;
302 default: 305 default:
303 return DirectionNone; 306 return kDirectionNone;
304 } 307 }
305 } 308 }
306 309
307 static int parseSuppresedChars(const std::string& str) { 310 static int ParseSuppresedChars(const std::string& str) {
308 std::vector<std::string> strings = parseStringList(str); 311 std::vector<std::string> strings = ParseStringList(str);
309 int suppresedChars = 0; 312 int suppresed_chars = 0;
310 for (size_t x = 0; x < strings.size(); x++) { 313 for (size_t x = 0; x < strings.size(); x++) {
311 if (strings[x] == "x") 314 if (strings[x] == "x")
312 suppresedChars++; 315 suppresed_chars++;
313 } 316 }
314 return suppresedChars; 317 return suppresed_chars;
315 } 318 }
316 319
317 template <class Runner> 320 template <class Runner>
318 void CharacterHarness<Runner>::parse(std::istream& bidiTestFile) { 321 void CharacterHarness<Runner>::Parse(std::istream& bidi_test_file) {
319 std::string line; 322 std::string line;
320 size_t lineNumber = 0; 323 size_t line_number = 0;
321 while (std::getline(bidiTestFile, line)) { 324 while (std::getline(bidi_test_file, line)) {
322 lineNumber++; 325 line_number++;
323 326
324 const std::string originalLine = line; 327 const std::string original_line = line;
325 size_t commentStart = line.find_first_of('#'); 328 size_t comment_start = line.find_first_of('#');
326 if (commentStart != std::string::npos) 329 if (comment_start != std::string::npos)
327 line = line.substr(0, commentStart); 330 line = line.substr(0, comment_start);
328 trim(line); 331 Trim(line);
329 if (line.empty()) 332 if (line.empty())
330 continue; 333 continue;
331 334
332 // Field 0: list of uchars as 4 char strings 335 // Field 0: list of uchars as 4 char strings
333 size_t separatorIndex = line.find_first_of(';'); 336 size_t separator_index = line.find_first_of(';');
334 if (separatorIndex == std::string::npos) { 337 if (separator_index == std::string::npos) {
335 parseError(originalLine, lineNumber); 338 ParseError(original_line, line_number);
336 continue; 339 continue;
337 } 340 }
338 341
339 std::basic_string<UChar> testString = 342 std::basic_string<UChar> test_string =
340 parseUCharHexadecimalList(line.substr(0, separatorIndex)); 343 ParseUCharHexadecimalList(line.substr(0, separator_index));
341 if (testString.empty()) { 344 if (test_string.empty()) {
342 parseError(originalLine, lineNumber); 345 ParseError(original_line, line_number);
343 continue; 346 continue;
344 } 347 }
345 line = line.substr(separatorIndex + 1); 348 line = line.substr(separator_index + 1);
346 349
347 // Field 1: paragraph direction (0 LTR, 1 RTL, 2 AutoLTR) 350 // Field 1: paragraph direction (0 LTR, 1 RTL, 2 AutoLTR)
348 separatorIndex = line.find_first_of(';'); 351 separator_index = line.find_first_of(';');
349 if (separatorIndex == std::string::npos) { 352 if (separator_index == std::string::npos) {
350 parseError(originalLine, lineNumber); 353 ParseError(original_line, line_number);
351 continue; 354 continue;
352 } 355 }
353 356
354 ParagraphDirection paragraphDirection = 357 ParagraphDirection paragraph_direction =
355 parseParagraphDirection(line.substr(0, separatorIndex)); 358 ParseParagraphDirection(line.substr(0, separator_index));
356 if (paragraphDirection == DirectionNone) { 359 if (paragraph_direction == kDirectionNone) {
357 parseError(originalLine, lineNumber); 360 ParseError(original_line, line_number);
358 continue; 361 continue;
359 } 362 }
360 line = line.substr(separatorIndex + 1); 363 line = line.substr(separator_index + 1);
361 364
362 // Field 2: resolved paragraph embedding level 365 // Field 2: resolved paragraph embedding level
363 separatorIndex = line.find_first_of(';'); 366 separator_index = line.find_first_of(';');
364 if (separatorIndex == std::string::npos) { 367 if (separator_index == std::string::npos) {
365 parseError(originalLine, lineNumber); 368 ParseError(original_line, line_number);
366 continue; 369 continue;
367 } 370 }
368 371
369 int paragraphEmbeddingLevel = parseInt(line.substr(0, separatorIndex)); 372 int paragraph_embedding_level = ParseInt(line.substr(0, separator_index));
370 if (paragraphEmbeddingLevel < 0) { 373 if (paragraph_embedding_level < 0) {
371 parseError(originalLine, lineNumber); 374 ParseError(original_line, line_number);
372 continue; 375 continue;
373 } 376 }
374 line = line.substr(separatorIndex + 1); 377 line = line.substr(separator_index + 1);
375 378
376 // Field 3: List of resolved levels 379 // Field 3: List of resolved levels
377 separatorIndex = line.find_first_of(';'); 380 separator_index = line.find_first_of(';');
378 if (separatorIndex == std::string::npos) { 381 if (separator_index == std::string::npos) {
379 parseError(originalLine, lineNumber); 382 ParseError(original_line, line_number);
380 continue; 383 continue;
381 } 384 }
382 385
383 int supressedChars = parseSuppresedChars(line.substr(0, separatorIndex)); 386 int supressed_chars = ParseSuppresedChars(line.substr(0, separator_index));
384 std::vector<int> levels = parseLevels(line.substr(0, separatorIndex)); 387 std::vector<int> levels = ParseLevels(line.substr(0, separator_index));
385 if (testString.size() != levels.size()) { 388 if (test_string.size() != levels.size()) {
386 parseError(originalLine, lineNumber); 389 ParseError(original_line, line_number);
387 continue; 390 continue;
388 } 391 }
389 line = line.substr(separatorIndex + 1); 392 line = line.substr(separator_index + 1);
390 393
391 // Field 4: visual ordering of characters 394 // Field 4: visual ordering of characters
392 separatorIndex = line.find_first_of(';'); 395 separator_index = line.find_first_of(';');
393 if (separatorIndex != std::string::npos) { 396 if (separator_index != std::string::npos) {
394 parseError(originalLine, lineNumber); 397 ParseError(original_line, line_number);
395 continue; 398 continue;
396 } 399 }
397 400
398 std::vector<int> visualOrdering = parseIntList(line); 401 std::vector<int> visual_ordering = ParseIntList(line);
399 if (testString.size() - supressedChars != visualOrdering.size()) { 402 if (test_string.size() - supressed_chars != visual_ordering.size()) {
400 parseError(originalLine, lineNumber); 403 ParseError(original_line, line_number);
401 continue; 404 continue;
402 } 405 }
403 406
404 m_runner.RunTest(testString, visualOrdering, levels, paragraphDirection, 407 runner_.RunTest(test_string, visual_ordering, levels, paragraph_direction,
405 originalLine, lineNumber); 408 original_line, line_number);
406 } 409 }
407 } 410 }
408 411
409 } // namespace bidi_test 412 } // namespace bidi_test
410 413
411 #endif // BidiTestHarness_h 414 #endif // BidiTestHarness_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/BidiResolverTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698