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

Side by Side Diff: source/test/cintltst/sorttest.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/reapits.c ('k') | source/test/cintltst/spreptst.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 ******************************************************************************* 2 *******************************************************************************
3 * 3 *
4 * Copyright (C) 2003-2013, International Business Machines 4 * Copyright (C) 2003-2014, International Business Machines
5 * Corporation and others. All Rights Reserved. 5 * Corporation and others. All Rights Reserved.
6 * 6 *
7 ******************************************************************************* 7 *******************************************************************************
8 * file name: sorttest.c 8 * file name: sorttest.c
9 * encoding: US-ASCII 9 * encoding: US-ASCII
10 * tab size: 8 (not used) 10 * tab size: 8 (not used)
11 * indentation:4 11 * indentation:4
12 * 12 *
13 * created on: 2003aug04 13 * created on: 2003aug04
14 * created by: Markus W. Scherer 14 * created by: Markus W. Scherer
15 * 15 *
16 * Test internal sorting functions. 16 * Test internal sorting functions.
17 */ 17 */
18 18
19 #include <stdio.h> 19 #include <stdio.h>
20 20
21 #include "unicode/utypes.h" 21 #include "unicode/utypes.h"
22 #include "unicode/ucol.h" 22 #include "unicode/ucol.h"
23 #include "unicode/ustring.h" 23 #include "unicode/ustring.h"
24 #include "cmemory.h" 24 #include "cmemory.h"
25 #include "cintltst.h" 25 #include "cintltst.h"
26 #include "uarrsort.h" 26 #include "uarrsort.h"
27 27
28 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
29
30 static void 28 static void
31 SortTest() { 29 SortTest() {
32 uint16_t small[]={ 8, 1, 2, 5, 4, 3, 7, 6 }; 30 uint16_t small[]={ 8, 1, 2, 5, 4, 3, 7, 6 };
33 int32_t medium[]={ 10, 8, 1, 2, 5, 5, -1, 6, 4, 3, 9, 7, 5 }; 31 int32_t medium[]={ 10, 8, 1, 2, 5, 5, -1, 6, 4, 3, 9, 7, 5 };
34 uint32_t large[]={ 21, 10, 20, 19, 11, 12, 13, 10, 10, 10, 10, 32 uint32_t large[]={ 21, 10, 20, 19, 11, 12, 13, 10, 10, 10, 10,
35 8, 1, 2, 5, 10, 10, 4, 17, 18, 3, 9, 10, 7, 6, 14, 15, 16 }; 33 8, 1, 2, 5, 10, 10, 4, 17, 18, 3, 9, 10, 7, 6, 14, 15, 16 };
36 34
37 int32_t i; 35 int32_t i;
38 UErrorCode errorCode; 36 UErrorCode errorCode;
39 37
40 /* sort small array (stable) */ 38 /* sort small array (stable) */
41 errorCode=U_ZERO_ERROR; 39 errorCode=U_ZERO_ERROR;
42 uprv_sortArray(small, LENGTHOF(small), sizeof(small[0]), uprv_uint16Comparat or, NULL, TRUE, &errorCode); 40 uprv_sortArray(small, UPRV_LENGTHOF(small), sizeof(small[0]), uprv_uint16Com parator, NULL, TRUE, &errorCode);
43 if(U_FAILURE(errorCode)) { 41 if(U_FAILURE(errorCode)) {
44 log_err("uprv_sortArray(small) failed - %s\n", u_errorName(errorCode)); 42 log_err("uprv_sortArray(small) failed - %s\n", u_errorName(errorCode));
45 return; 43 return;
46 } 44 }
47 for(i=1; i<LENGTHOF(small); ++i) { 45 for(i=1; i<UPRV_LENGTHOF(small); ++i) {
48 if(small[i-1]>small[i]) { 46 if(small[i-1]>small[i]) {
49 log_err("uprv_sortArray(small) mis-sorted [%d]=%u > [%d]=%u\n", i-1, small[i-1], i, small[i]); 47 log_err("uprv_sortArray(small) mis-sorted [%d]=%u > [%d]=%u\n", i-1, small[i-1], i, small[i]);
50 return; 48 return;
51 } 49 }
52 } 50 }
53 51
54 /* for medium, add bits that will not be compared, to test stability */ 52 /* for medium, add bits that will not be compared, to test stability */
55 for(i=0; i<LENGTHOF(medium); ++i) { 53 for(i=0; i<UPRV_LENGTHOF(medium); ++i) {
56 medium[i]=(medium[i]<<4)|i; 54 medium[i]=(medium[i]<<4)|i;
57 } 55 }
58 56
59 /* sort medium array (stable) */ 57 /* sort medium array (stable) */
60 uprv_sortArray(medium, LENGTHOF(medium), sizeof(medium[0]), uprv_int32Compar ator, NULL, TRUE, &errorCode); 58 uprv_sortArray(medium, UPRV_LENGTHOF(medium), sizeof(medium[0]), uprv_int32C omparator, NULL, TRUE, &errorCode);
61 if(U_FAILURE(errorCode)) { 59 if(U_FAILURE(errorCode)) {
62 log_err("uprv_sortArray(medium) failed - %s\n", u_errorName(errorCode)); 60 log_err("uprv_sortArray(medium) failed - %s\n", u_errorName(errorCode));
63 return; 61 return;
64 } 62 }
65 for(i=1; i<LENGTHOF(medium); ++i) { 63 for(i=1; i<UPRV_LENGTHOF(medium); ++i) {
66 if(medium[i-1]>=medium[i]) { 64 if(medium[i-1]>=medium[i]) {
67 log_err("uprv_sortArray(medium) mis-sorted [%d]=%u > [%d]=%u\n", i-1 , medium[i-1], i, medium[i]); 65 log_err("uprv_sortArray(medium) mis-sorted [%d]=%u > [%d]=%u\n", i-1 , medium[i-1], i, medium[i]);
68 return; 66 return;
69 } 67 }
70 } 68 }
71 69
72 /* sort large array (not stable) */ 70 /* sort large array (not stable) */
73 errorCode=U_ZERO_ERROR; 71 errorCode=U_ZERO_ERROR;
74 uprv_sortArray(large, LENGTHOF(large), sizeof(large[0]), uprv_uint32Comparat or, NULL, FALSE, &errorCode); 72 uprv_sortArray(large, UPRV_LENGTHOF(large), sizeof(large[0]), uprv_uint32Com parator, NULL, FALSE, &errorCode);
75 if(U_FAILURE(errorCode)) { 73 if(U_FAILURE(errorCode)) {
76 log_err("uprv_sortArray(large) failed - %s\n", u_errorName(errorCode)); 74 log_err("uprv_sortArray(large) failed - %s\n", u_errorName(errorCode));
77 return; 75 return;
78 } 76 }
79 for(i=1; i<LENGTHOF(large); ++i) { 77 for(i=1; i<UPRV_LENGTHOF(large); ++i) {
80 if(large[i-1]>large[i]) { 78 if(large[i-1]>large[i]) {
81 log_err("uprv_sortArray(large) mis-sorted [%d]=%u > [%d]=%u\n", i-1, large[i-1], i, large[i]); 79 log_err("uprv_sortArray(large) mis-sorted [%d]=%u > [%d]=%u\n", i-1, large[i-1], i, large[i]);
82 return; 80 return;
83 } 81 }
84 } 82 }
85 } 83 }
86 84
87 #if !UCONFIG_NO_COLLATION 85 #if !UCONFIG_NO_COLLATION
88 86
89 /* 87 /*
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void 203 void
206 addSortTest(TestNode** root); 204 addSortTest(TestNode** root);
207 205
208 void 206 void
209 addSortTest(TestNode** root) { 207 addSortTest(TestNode** root) {
210 addTest(root, &SortTest, "tsutil/sorttest/SortTest"); 208 addTest(root, &SortTest, "tsutil/sorttest/SortTest");
211 #if !UCONFIG_NO_COLLATION 209 #if !UCONFIG_NO_COLLATION
212 addTest(root, &StableSortTest, "tsutil/sorttest/StableSortTest"); 210 addTest(root, &StableSortTest, "tsutil/sorttest/StableSortTest");
213 #endif 211 #endif
214 } 212 }
OLDNEW
« no previous file with comments | « source/test/cintltst/reapits.c ('k') | source/test/cintltst/spreptst.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698