OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef BidiTestHarness_h | 31 #ifndef BidiTestHarness_h |
32 #define BidiTestHarness_h | 32 #define BidiTestHarness_h |
33 | 33 |
| 34 #include <stdio.h> |
34 #include <istream> | 35 #include <istream> |
35 #include <map> | 36 #include <map> |
36 #include <stdio.h> | |
37 #include <string> | 37 #include <string> |
38 #include <vector> | 38 #include <vector> |
39 | 39 |
40 // FIXME: We don't have any business owning this code. We should try to | 40 // FIXME: We don't have any business owning this code. We should try to |
41 // upstream this to unicode.org if possible (for other implementations to use). | 41 // upstream this to unicode.org if possible (for other implementations to use). |
42 // Unicode.org provides a reference implmentation, including parser: | 42 // Unicode.org provides a reference implmentation, including parser: |
43 // http://www.unicode.org/Public/PROGRAMS/BidiReferenceC/6.3.0/source/brtest.c | 43 // http://www.unicode.org/Public/PROGRAMS/BidiReferenceC/6.3.0/source/brtest.c |
44 // But it, like the other implementations I've found, is rather tied to | 44 // But it, like the other implementations I've found, is rather tied to |
45 // the algorithms it is testing. This file seeks to only implement the parser | 45 // the algorithms it is testing. This file seeks to only implement the parser |
46 // bits. | 46 // bits. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 251 } |
252 test_string = ParseTestString(line.substr(0, seperator_index)); | 252 test_string = ParseTestString(line.substr(0, seperator_index)); |
253 if (!ParseParagraphDirectionMask(line.substr(seperator_index + 1), | 253 if (!ParseParagraphDirectionMask(line.substr(seperator_index + 1), |
254 paragraph_direction_mask)) { | 254 paragraph_direction_mask)) { |
255 ParseError(original_line, line_number); | 255 ParseError(original_line, line_number); |
256 continue; | 256 continue; |
257 } | 257 } |
258 | 258 |
259 if (paragraph_direction_mask & kDirectionAutoLTR) { | 259 if (paragraph_direction_mask & kDirectionAutoLTR) { |
260 runner_.RunTest(test_string, reorder, levels, kDirectionAutoLTR, | 260 runner_.RunTest(test_string, reorder, levels, kDirectionAutoLTR, |
261 original_line, line_number); | 261 original_line, line_number); |
262 } | 262 } |
263 if (paragraph_direction_mask & kDirectionLTR) { | 263 if (paragraph_direction_mask & kDirectionLTR) { |
264 runner_.RunTest(test_string, reorder, levels, kDirectionLTR, | 264 runner_.RunTest(test_string, reorder, levels, kDirectionLTR, |
265 original_line, line_number); | 265 original_line, line_number); |
266 } | 266 } |
267 if (paragraph_direction_mask & kDirectionRTL) { | 267 if (paragraph_direction_mask & kDirectionRTL) { |
268 runner_.RunTest(test_string, reorder, levels, kDirectionRTL, | 268 runner_.RunTest(test_string, reorder, levels, kDirectionRTL, |
269 original_line, line_number); | 269 original_line, line_number); |
270 } | 270 } |
271 } | 271 } |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 template <class Runner> | 275 template <class Runner> |
276 class CharacterHarness { | 276 class CharacterHarness { |
277 public: | 277 public: |
278 CharacterHarness(Runner& runner) : runner_(runner) {} | 278 CharacterHarness(Runner& runner) : runner_(runner) {} |
279 void Parse(std::istream& bidi_test_file); | 279 void Parse(std::istream& bidi_test_file); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 continue; | 398 continue; |
399 } | 399 } |
400 | 400 |
401 std::vector<int> visual_ordering = ParseIntList(line); | 401 std::vector<int> visual_ordering = ParseIntList(line); |
402 if (test_string.size() - supressed_chars != visual_ordering.size()) { | 402 if (test_string.size() - supressed_chars != visual_ordering.size()) { |
403 ParseError(original_line, line_number); | 403 ParseError(original_line, line_number); |
404 continue; | 404 continue; |
405 } | 405 } |
406 | 406 |
407 runner_.RunTest(test_string, visual_ordering, levels, paragraph_direction, | 407 runner_.RunTest(test_string, visual_ordering, levels, paragraph_direction, |
408 original_line, line_number); | 408 original_line, line_number); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 } // namespace bidi_test | 412 } // namespace bidi_test |
413 | 413 |
414 #endif // BidiTestHarness_h | 414 #endif // BidiTestHarness_h |
OLD | NEW |