LEFT | RIGHT |
(no file at all) | |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 /* | 3 /* |
4 ******************************************************************************* | 4 ******************************************************************************* |
5 * Copyright (C) 1996-2016, International Business Machines Corporation and | 5 * Copyright (C) 1996-2016, International Business Machines Corporation and |
6 * others. All Rights Reserved. | 6 * others. All Rights Reserved. |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 */ | 8 */ |
9 package com.ibm.icu.dev.test.rbbi; | 9 package com.ibm.icu.dev.test.rbbi; |
10 | 10 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 assertEquals("Locales do not participate in BreakIterator equality.", bi
En, biFr); | 481 assertEquals("Locales do not participate in BreakIterator equality.", bi
En, biFr); |
482 | 482 |
483 RuleBasedBreakIterator cloneEn = (RuleBasedBreakIterator)biEn.clone(); | 483 RuleBasedBreakIterator cloneEn = (RuleBasedBreakIterator)biEn.clone(); |
484 assertEquals("", biEn, cloneEn); | 484 assertEquals("", biEn, cloneEn); |
485 assertEquals("", ULocale.ENGLISH, cloneEn.getLocale(ULocale.VALID_LOCALE
)); | 485 assertEquals("", ULocale.ENGLISH, cloneEn.getLocale(ULocale.VALID_LOCALE
)); |
486 | 486 |
487 RuleBasedBreakIterator cloneFr = (RuleBasedBreakIterator)biFr.clone(); | 487 RuleBasedBreakIterator cloneFr = (RuleBasedBreakIterator)biFr.clone(); |
488 assertEquals("", biFr, cloneFr); | 488 assertEquals("", biFr, cloneFr); |
489 assertEquals("", ULocale.FRENCH, cloneFr.getLocale(ULocale.VALID_LOCALE)
); | 489 assertEquals("", ULocale.FRENCH, cloneFr.getLocale(ULocale.VALID_LOCALE)
); |
490 } | 490 } |
| 491 |
| 492 static class T13512Thread extends Thread { |
| 493 private String fText; |
| 494 public List fBoundaries; |
| 495 public List fExpectedBoundaries; |
| 496 |
| 497 T13512Thread(String text) { |
| 498 fText = text; |
| 499 fExpectedBoundaries = getBoundary(fText); |
| 500 } |
| 501 @Override |
| 502 public void run() { |
| 503 for (int i= 0; i<10000; ++i) { |
| 504 fBoundaries = getBoundary(fText); |
| 505 if (!fBoundaries.equals(fExpectedBoundaries)) { |
| 506 break; |
| 507 } |
| 508 } |
| 509 } |
| 510 private static final BreakIterator BREAK_ITERATOR_CACHE = BreakIterator.
getWordInstance(ULocale.ROOT); |
| 511 public static List<Integer> getBoundary(String toParse) { |
| 512 List<Integer> retVal = new ArrayList<Integer>(); |
| 513 BreakIterator bi = (BreakIterator) BREAK_ITERATOR_CACHE.clone(); |
| 514 bi.setText(toParse); |
| 515 for (int boundary=bi.first(); boundary != BreakIterator.DONE; bounda
ry = bi.next()) { |
| 516 retVal.add(boundary); |
| 517 } |
| 518 return retVal; |
| 519 } |
| 520 } |
| 521 |
| 522 @Test |
| 523 public void TestBug13512() { |
| 524 String japanese = "コンピューターは、本質的には数字しか扱うことができません。コンピューターは、文字や記号などのそれぞれに番号
を割り振る" |
| 525 + "ことによって扱えるようにします。ユニコードが出来るまでは、これらの番号を割り振る仕組みが何百種類も存在しました。どの一つを
とっても、十分な" |
| 526 + "文字を含んではいませんでした。例えば、欧州連合一つを見ても、そのすべての言語をカバーするためには、いくつかの異なる符号化の
仕" |
| 527 + "組みが必要でした。英語のような一つの言語に限っても、一つだけの符号化の仕組みでは、一般的に使われるすべての文字、句読点、技
術" |
| 528 + "的な記号などを扱うには不十分でした。"; |
| 529 |
| 530 String thai = "โดยพื้นฐานแล้ว, คอมพิวเตอร์จะเกี่ยวข้องกับเรื่องของตัวเลข
. คอมพิวเตอร์จัดเก็บตัวอักษรและอักขระอื่นๆ" |
| 531 + " โดยการกำหนดหมายเลขให้สำหรับแต่ละตัว. ก่อนหน้าที่๊ Unicode จะ
ถูกสร้างขึ้น, ได้มีระบบ encoding " |
| 532 + "อยู่หลายร้อยระบบสำหรับการกำหนดหมายเลขเหล่านี้. ไม่มี encoding
ใดที่มีจำนวนตัวอักขระมากเพียงพอ: ยกตัวอย่างเช่น, " |
| 533 + "เฉพาะในกลุ่มสหภาพยุโรปเพียงแห่งเดียว ก็ต้องการหลาย encoding ใ
นการครอบคลุมทุกภาษาในกลุ่ม. " |
| 534 + "หรือแม้แต่ในภาษาเดี่ยว เช่น ภาษาอังกฤษ ก็ไม่มี encoding ใดที่
เพียงพอสำหรับทุกตัวอักษร, " |
| 535 + "เครื่องหมายวรรคตอน และสัญลักษณ์ทางเทคนิคที่ใช้กันอยู่ทั่วไป.\
n" + |
| 536 "ระบบ encoding เหล่านี้ยังขัดแย้งซึ่งกันและกัน. นั่นก็คือ, ในสอง
encoding สามารถใช้หมายเลขเดียวกันสำหรับตัวอักขระสองตัวที่แตกต่างกัน," |
| 537 + "หรือใช้หมายเลขต่างกันสำหรับอักขระตัวเดียวกัน. ในระบบคอมพิวเตอ
ร์ (โดยเฉพาะเซิร์ฟเวอร์) ต้องมีการสนับสนุนหลาย" |
| 538 + " encoding; และเมื่อข้อมูลที่ผ่านไปมาระหว่างการเข้ารหัสหรือแพล
็ตฟอร์มที่ต่างกัน, ข้อมูลนั้นจะเสี่ยงต่อการผิดพลาดเสียหาย."; |
| 539 |
| 540 T13512Thread t1 = new T13512Thread(thai); |
| 541 T13512Thread t2 = new T13512Thread(japanese); |
| 542 try { |
| 543 t1.start(); t2.start(); |
| 544 t1.join(); t2.join(); |
| 545 } catch (Exception e) { |
| 546 fail(e.toString()); |
| 547 } |
| 548 assertEquals("", t1.fExpectedBoundaries, t1.fBoundaries); |
| 549 assertEquals("", t2.fExpectedBoundaries, t2.fBoundaries); |
| 550 } |
491 } | 551 } |
LEFT | RIGHT |