Annotation of embedaddon/php/ext/intl/tests/collator_get_sort_key.phpt, revision 1.1.1.3
1.1 misho 1: --TEST--
2: collator_get_sort_key()
3: --SKIPIF--
4: <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
1.1.1.2 misho 5: <?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
1.1.1.3 ! misho 6: <?php /* XXX Obviously it fails somewhere between >= 4.8 and < 51.2 */
! 7: if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
1.1 misho 8: --FILE--
9: <?php
10:
11: /*
12: * Get sort keys using various locales
13: */
14: function sort_arrays( $locale, $data )
15: {
16: $res_str = '';
17:
18: $coll = ut_coll_create( $locale );
19:
20: foreach($data as $value) {
21: $res_val = ut_coll_get_sort_key( $coll, $value );
1.1.1.2 misho 22: $res_str .= "source: ".$value."\n".
23: "key: ".bin2hex($res_val)."\n";
1.1 misho 24: }
25:
26: return $res_str;
27: }
28:
29:
30: function ut_main()
31: {
32: $res_str = '';
33:
34: // Regular strings keys
35: $test_params = array(
36: 'abc', 'abd', 'aaa',
37: 'аа', 'а', 'z',
38: '', null , '3',
39: 'y' , 'i' , 'k'
40: );
41:
42: $res_str .= sort_arrays( 'en_US', $test_params );
43:
44: // Sort a non-ASCII array using ru_RU locale.
45: $test_params = array(
46: 'абг', 'абв', 'жжж', 'эюя'
47: );
48:
49: $res_str .= sort_arrays( 'ru_RU', $test_params );
50:
51: // Sort an array using Lithuanian locale.
52: $res_str .= sort_arrays( 'lt_LT', $test_params );
53:
54: return $res_str . "\n";
55: }
56:
57: include_once( 'ut_common.inc' );
58: ut_run();
59: ?>
60: --EXPECT--
61: source: abc
1.1.1.2 misho 62: key: 27292b01070107
1.1 misho 63: source: abd
1.1.1.2 misho 64: key: 27292d01070107
1.1 misho 65: source: aaa
1.1.1.2 misho 66: key: 27272701070107
67: source: аа
68: key: 5c0a0a01060106
69: source: а
70: key: 5c0a01050105
1.1 misho 71: source: z
1.1.1.2 misho 72: key: 5901050105
73: source:
74: key: 0101
75: source:
76: key: 0101
1.1 misho 77: source: 3
1.1.1.2 misho 78: key: 1801050105
1.1 misho 79: source: y
1.1.1.2 misho 80: key: 5701050105
1.1 misho 81: source: i
1.1.1.2 misho 82: key: 3701050105
1.1 misho 83: source: k
1.1.1.2 misho 84: key: 3b01050105
85: source: абг
86: key: 5c0a161a01070107
87: source: абв
88: key: 5c0a161801070107
89: source: жжж
90: key: 5c3a3a3a01070107
91: source: эюя
92: key: 5d3b3f4501070107
93: source: абг
94: key: 5c0a161a01070107
95: source: абв
96: key: 5c0a161801070107
97: source: жжж
98: key: 5c3a3a3a01070107
99: source: эюя
1.1.1.3 ! misho 100: key: 5d3b3f4501070107
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>