php-src/ext/standard/tests/strings/money_format_basic1.phpt
Peter Kokot b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:32:30 +02:00

80 lines
2.6 KiB
PHP

--TEST--
Test money_format() function : basic functionality using national currency symbols
--SKIPIF--
<?php
if (!function_exists('money_format')) {
die("SKIP money_format - not supported\n");
}
?>
--FILE--
<?php
/* Prototype : string money_format ( string $format , float $number )
* Description: Formats a number as a currency string
* Source code: ext/standard/string.c
*/
// ===========================================================================================
// = We do not test for exact return-values, as those might be different between OS-versions =
// ===========================================================================================
echo "*** Testing money_format() : basic functionality***\n";
$value = 1234.5678;
$negative_value = -1234.5678;
// Format with 14 positions of width, 8 digits of
// left precision, 2 of right precision using national
// format for en_US
echo "Format values with 14 positions, 8 digits to left, 2 to right using national format\n";
echo gettype(money_format('%14#8.2n', $value))."\n";
echo gettype(money_format('%14#8.2n', $negative_value))."\n";
// Same again but use '(' for negative values
echo "Format again but with ( for negative values\n";
echo gettype(money_format('%(14#8.2n', $value))."\n";
echo gettype(money_format('%(14#8.2n', $negative_value))."\n";
// Same again but use a '0' for padding character
echo "Format with 0 for padding character\n";
echo gettype(money_format('%=014#8.2n', $value))."\n";
echo gettype(money_format('%=014#8.2n', $negative_value))."\n";
// Same again but use a '*' for padding character
echo "Format again with * for padding character\n";
echo gettype(money_format('%=*14#8.2n', $value))."\n";
echo gettype(money_format('%=*14#8.2n', $negative_value))."\n";
// Same again but disable grouping character
echo "Format again but disable grouping character\n";
echo gettype(money_format('%=*^14#8.2n', $value))."\n";
echo gettype(money_format('%=*^14#8.2n', $negative_value))."\n";
// Same again but suppress currency symbol
echo "Format again suppress currency symbol\n";
echo gettype(money_format('%=*!14#8.2n', $value))."\n";
echo gettype(money_format('%=*!14#8.2n', $negative_value))."\n";
?>
===DONE===
--EXPECT--
*** Testing money_format() : basic functionality***
Format values with 14 positions, 8 digits to left, 2 to right using national format
string
string
Format again but with ( for negative values
string
string
Format with 0 for padding character
string
string
Format again with * for padding character
string
string
Format again but disable grouping character
string
string
Format again suppress currency symbol
string
string
===DONE===