Annotation of embedaddon/php/ext/intl/tests/collator_get_sort_key_variant2.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>