Annotation of embedaddon/php/ext/intl/tests/collator_get_sort_key.phpt, revision 1.1.1.2

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       misho       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 );
1.1.1.2 ! misho      20:                $res_str .= "source: ".$value."\n".
        !            21:                                        "key: ".bin2hex($res_val)."\n";
1.1       misho      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
1.1.1.2 ! misho      60: key: 27292b01070107
1.1       misho      61: source: abd
1.1.1.2 ! misho      62: key: 27292d01070107
1.1       misho      63: source: aaa
1.1.1.2 ! misho      64: key: 27272701070107
        !            65: source: аа
        !            66: key: 5c0a0a01060106
        !            67: source: а
        !            68: key: 5c0a01050105
1.1       misho      69: source: z
1.1.1.2 ! misho      70: key: 5901050105
        !            71: source: 
        !            72: key: 0101
        !            73: source: 
        !            74: key: 0101
1.1       misho      75: source: 3
1.1.1.2 ! misho      76: key: 1801050105
1.1       misho      77: source: y
1.1.1.2 ! misho      78: key: 5701050105
1.1       misho      79: source: i
1.1.1.2 ! misho      80: key: 3701050105
1.1       misho      81: source: k
1.1.1.2 ! misho      82: key: 3b01050105
        !            83: source: абг
        !            84: key: 5c0a161a01070107
        !            85: source: абв
        !            86: key: 5c0a161801070107
        !            87: source: жжж
        !            88: key: 5c3a3a3a01070107
        !            89: source: эюя
        !            90: key: 5d3b3f4501070107
        !            91: source: абг
        !            92: key: 5c0a161a01070107
        !            93: source: абв
        !            94: key: 5c0a161801070107
        !            95: source: жжж
        !            96: key: 5c3a3a3a01070107
        !            97: source: эюя
        !            98: key: 5d3b3f4501070107

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