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

Side by Side Diff: source/test/cintltst/utf16tst.c

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 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 | « source/test/cintltst/usettest.c ('k') | source/test/cintltst/utf8tst.c » ('j') | 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: 2 * COPYRIGHT:
3 * Copyright (c) 1998-2012, International Business Machines Corporation and 3 * Copyright (c) 1998-2014, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 /* 6 /*
7 * File test.c 7 * File test.c
8 * 8 *
9 * Modification History: 9 * Modification History:
10 * 10 *
11 * Date Name Description 11 * Date Name Description
12 * 05/01/2000 Madhu Creation 12 * 05/01/2000 Madhu Creation
13 ******************************************************************************* 13 *******************************************************************************
14 */ 14 */
15 15
16 #include "unicode/utypes.h" 16 #include "unicode/utypes.h"
17 #include "unicode/utf16.h" 17 #include "unicode/utf16.h"
18 #include "unicode/ustring.h" 18 #include "unicode/ustring.h"
19 #include "cmemory.h" 19 #include "cmemory.h"
20 #include "cstring.h" 20 #include "cstring.h"
21 #include "cintltst.h" 21 #include "cintltst.h"
22 #include <stdio.h> 22 #include <stdio.h>
23 23
24 #define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
25
26 static void printUChars(const UChar *uchars); 24 static void printUChars(const UChar *uchars);
27 25
28 static void TestCodeUnitValues(void); 26 static void TestCodeUnitValues(void);
29 static void TestCharLength(void); 27 static void TestCharLength(void);
30 static void TestGetChar(void); 28 static void TestGetChar(void);
31 static void TestNextPrevChar(void); 29 static void TestNextPrevChar(void);
32 static void TestNulTerminated(void); 30 static void TestNulTerminated(void);
33 static void TestFwdBack(void); 31 static void TestFwdBack(void);
34 static void TestSetChar(void); 32 static void TestSetChar(void);
35 static void TestAppendChar(void); 33 static void TestAppendChar(void);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 /* none from this line */ 733 /* none from this line */
736 0, 0x400 734 0, 0x400
737 }; 735 };
738 736
739 UChar buffer[100]; 737 UChar buffer[100];
740 UChar32 c; 738 UChar32 c;
741 int32_t i, length; 739 int32_t i, length;
742 UBool isError, expectIsError, wrongIsError; 740 UBool isError, expectIsError, wrongIsError;
743 741
744 length=0; 742 length=0;
745 for(i=0; i<LENGTHOF(codePoints); ++i) { 743 for(i=0; i<UPRV_LENGTHOF(codePoints); ++i) {
746 c=codePoints[i]; 744 c=codePoints[i];
747 if(c<0 || 0x10ffff<c) { 745 if(c<0 || 0x10ffff<c) {
748 continue; /* skip non-code points for U16_APPEND_UNSAFE */ 746 continue; /* skip non-code points for U16_APPEND_UNSAFE */
749 } 747 }
750 748
751 U16_APPEND_UNSAFE(buffer, length, c); 749 U16_APPEND_UNSAFE(buffer, length, c);
752 } 750 }
753 if(length!=LENGTHOF(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, length* U_SIZEOF_UCHAR)) { 751 if(length!=UPRV_LENGTHOF(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, le ngth*U_SIZEOF_UCHAR)) {
754 log_err("U16_APPEND_UNSAFE did not generate the expected output\n"); 752 log_err("U16_APPEND_UNSAFE did not generate the expected output\n");
755 } 753 }
756 754
757 length=0; 755 length=0;
758 wrongIsError=FALSE; 756 wrongIsError=FALSE;
759 for(i=0; i<LENGTHOF(codePoints); ++i) { 757 for(i=0; i<UPRV_LENGTHOF(codePoints); ++i) {
760 c=codePoints[i]; 758 c=codePoints[i];
761 expectIsError= c<0 || 0x10ffff<c; /* || U_IS_SURROGATE(c); */ /* surroga tes in UTF-32 shouldn't be used, but it's okay to pass them around internally. * / 759 expectIsError= c<0 || 0x10ffff<c; /* || U_IS_SURROGATE(c); */ /* surroga tes in UTF-32 shouldn't be used, but it's okay to pass them around internally. * /
762 isError=FALSE; 760 isError=FALSE;
763 761
764 U16_APPEND(buffer, length, LENGTHOF(buffer), c, isError); 762 U16_APPEND(buffer, length, UPRV_LENGTHOF(buffer), c, isError);
765 wrongIsError|= isError!=expectIsError; 763 wrongIsError|= isError!=expectIsError;
766 } 764 }
767 if(wrongIsError) { 765 if(wrongIsError) {
768 log_err("U16_APPEND did not set isError correctly\n"); 766 log_err("U16_APPEND did not set isError correctly\n");
769 } 767 }
770 if(length!=LENGTHOF(expectSafe) || 0!=memcmp(buffer, expectSafe, length*U_SI ZEOF_UCHAR)) { 768 if(length!=UPRV_LENGTHOF(expectSafe) || 0!=memcmp(buffer, expectSafe, length *U_SIZEOF_UCHAR)) {
771 log_err("U16_APPEND did not generate the expected output\n"); 769 log_err("U16_APPEND did not generate the expected output\n");
772 } 770 }
773 } 771 }
774 772
775 static void TestSurrogate(){ 773 static void TestSurrogate(){
776 static UChar32 s[] = {0x10000, 0x10ffff, 0x50000, 0x100000, 0x1abcd}; 774 static UChar32 s[] = {0x10000, 0x10ffff, 0x50000, 0x100000, 0x1abcd};
777 int i = 0; 775 int i = 0;
778 while (i < 5) { 776 while (i < 5) {
779 UChar first = UTF_FIRST_SURROGATE(s[i]); 777 UChar first = UTF_FIRST_SURROGATE(s[i]);
780 UChar second = UTF_SECOND_SURROGATE(s[i]); 778 UChar second = UTF_SECOND_SURROGATE(s[i]);
(...skipping 12 matching lines...) Expand all
793 i ++; 791 i ++;
794 } 792 }
795 } 793 }
796 794
797 static void printUChars(const UChar *uchars){ 795 static void printUChars(const UChar *uchars){
798 int16_t i=0; 796 int16_t i=0;
799 for(i=0; i<u_strlen(uchars); i++){ 797 for(i=0; i<u_strlen(uchars); i++){
800 printf("%x ", *(uchars+i)); 798 printf("%x ", *(uchars+i));
801 } 799 }
802 } 800 }
OLDNEW
« no previous file with comments | « source/test/cintltst/usettest.c ('k') | source/test/cintltst/utf8tst.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698