formatter_parse.phpt 830 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. numfmt_parse()
  3. --EXTENSIONS--
  4. intl
  5. --FILE--
  6. <?php
  7. /*
  8. * Number parsing.
  9. */
  10. function ut_main()
  11. {
  12. $res_str = '';
  13. // Test parsing float number.
  14. $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
  15. $res_str .= ut_nfmt_parse( $fmt, "123E-3" ) . "\n";
  16. // Test parsing float number as integer.
  17. $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
  18. $res_str .= ut_nfmt_parse( $fmt, "1.23", NumberFormatter::TYPE_INT32 ) . "\n";
  19. // Test specifying non-zero parsing start position.
  20. $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
  21. $pos = 2;
  22. $res_str .= ut_nfmt_parse( $fmt, "0.123 here", NumberFormatter::TYPE_DOUBLE, $pos ) . "\n";
  23. $res_str .= "$pos\n";
  24. return $res_str;
  25. }
  26. include_once( 'ut_common.inc' );
  27. ut_run();
  28. ?>
  29. --EXPECT--
  30. 0.123
  31. 1
  32. 123
  33. 5