1--TEST--
2numfmt_get/set_pattern()
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
7--FILE--
8<?php
9
10/*
11 * Get/set pattern.
12 */
13
14
15function ut_main()
16{
17    $res_str = '';
18    $test_value = 12345.123456;
19    $fmt = ut_nfmt_create( "en_US", NumberFormatter::PATTERN_DECIMAL );
20
21    // Get default patten.
22    $res_str .= "Default pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
23    $res_str .= "Formatting result: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
24
25    // Set a new pattern.
26    $res = ut_nfmt_set_pattern( $fmt, "0.0" );
27    if( $res === false )
28        $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
29
30    // Check if the pattern has been changed.
31    $res = ut_nfmt_get_pattern( $fmt );
32    if( $res === false )
33        $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
34    $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
35    $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
36
37    ut_nfmt_set_pattern($fmt, str_repeat('@', 200));
38    $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
39    $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
40
41    return $res_str;
42}
43
44include_once( 'ut_common.inc' );
45ut_run();
46
47?>
48--EXPECT--
49Default pattern: '#'
50Formatting result: 12345.123456
51New pattern: '0.0'
52Formatted number: 12345.1
53New pattern: '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
54Formatted number: 12345.123456000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
55