summaryrefslogtreecommitdiff
path: root/ext/filter/tests/049.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/filter/tests/049.phpt')
-rw-r--r--ext/filter/tests/049.phpt34
1 files changed, 34 insertions, 0 deletions
diff --git a/ext/filter/tests/049.phpt b/ext/filter/tests/049.phpt
new file mode 100644
index 0000000..5a9977b
--- /dev/null
+++ b/ext/filter/tests/049.phpt
@@ -0,0 +1,34 @@
+--TEST--
+filter_var() and doubles with thousend separators
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$test = array(
+ '0' => 0.0,
+ '12345678900.1234567165' => 12345678900.1234567165,
+ '1,234,567,890.1234567165' => 1234567890.1234567165,
+ '-1,234,567,890.1234567165' => -1234567890.1234567165,
+ '1234,567,890.1234567165' => false,
+ '1,234,567,89.1234567165' => false,
+ '1,234,567,8900.1234567165' => false,
+ '1.234.567.890.1234567165' => false,
+ '1,234,567,8900.123,456' => false,
+);
+foreach ($test as $src => $dst) {
+ $out = filter_var($src, FILTER_VALIDATE_FLOAT, array("flags"=>FILTER_FLAG_ALLOW_THOUSAND));
+ if ($dst !== $out) {
+ if ($out === false) {
+ echo "$src -> false != $dst\n";
+ } elseif ($dst === false) {
+ echo "$src -> $out != false\n";
+ } else {
+ echo "$src -> $out != $dst\n";
+ }
+ }
+}
+
+echo "Ok\n";
+?>
+--EXPECT--
+Ok