Annotation of embedaddon/php/ext/intl/tests/collator_get_sort_key_variant3.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, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
                      6: --FILE--
                      7: <?php
                      8: 
                      9: /*
                     10:  * Get sort keys using various locales
                     11:  */
                     12: function sort_arrays( $locale, $data )
                     13: {
                     14:     $res_str = '';
                     15: 
                     16:     $coll = ut_coll_create( $locale );
                     17: 
                     18:        foreach($data as $value) {
                     19:                $res_val = ut_coll_get_sort_key( $coll, $value );
                     20:                $res_str .= "source: ".$value."\n".
                     21:                                        "key: ".bin2hex($res_val)."\n";
                     22:        }
                     23: 
                     24:     return $res_str;
                     25: }
                     26: 
                     27: 
                     28: function ut_main()
                     29: {
                     30:     $res_str = '';
                     31: 
                     32:     // Regular strings keys
                     33:     $test_params = array(
                     34:                'abc', 'abd', 'aaa',
                     35:                'аа', 'а', 'z',
                     36:                '', null , '3',
                     37:         'y'  , 'i'  , 'k'
                     38:     );
                     39: 
                     40:     $res_str .= sort_arrays( 'en_US', $test_params );
                     41: 
                     42:     // Sort a non-ASCII array using ru_RU locale.
                     43:     $test_params = array(
                     44:                'абг', 'абв', 'жжж', 'эюя'
                     45:     );
                     46: 
                     47:     $res_str .= sort_arrays( 'ru_RU', $test_params );
                     48: 
                     49:     // Sort an array using Lithuanian locale.
                     50:     $res_str .= sort_arrays( 'lt_LT', $test_params );
                     51: 
                     52:     return $res_str . "\n";
                     53: }
                     54: 
                     55: include_once( 'ut_common.inc' );
                     56: ut_run();
                     57: ?>
                     58: --EXPECT--
                     59: source: abc
                     60: key: 292b2d01070107
                     61: source: abd
                     62: key: 292b2f01070107
                     63: source: aaa
                     64: key: 29292901070107
                     65: source: аа
                     66: key: 5e090901060106
                     67: source: а
                     68: key: 5e0901050105
                     69: source: z
                     70: key: 5b01050105
                     71: source: 
                     72: key: 0101
                     73: source: 
                     74: key: 0101
                     75: source: 3
                     76: key: 1a01050105
                     77: source: y
                     78: key: 5901050105
                     79: source: i
                     80: key: 3901050105
                     81: source: k
                     82: key: 3d01050105
                     83: source: абг
                     84: key: 2809131701070107
                     85: source: абв
                     86: key: 2809131501070107
                     87: source: жжж
                     88: key: 2833333301070107
                     89: source: эюя
                     90: key: 28cdd1d501070107
                     91: source: абг
                     92: key: 5e09131701070107
                     93: source: абв
                     94: key: 5e09131501070107
                     95: source: жжж
                     96: key: 5e33333301070107
                     97: source: эюя
                     98: key: 5ecdd1d501070107

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