summaryrefslogtreecommitdiff
path: root/tests/unit/I18N/core/NumberFormatInfoTest.php
diff options
context:
space:
mode:
authorknut <>2006-01-30 21:30:35 +0000
committerknut <>2006-01-30 21:30:35 +0000
commit48b3a6a236d229a203f5c20c705c901ee43ca4c2 (patch)
treeac01a4c4947b27af122a966eb39cbbce29b53861 /tests/unit/I18N/core/NumberFormatInfoTest.php
parent14257165b0c3906181653c9a863edf87c1cf7366 (diff)
- Ported a few unit tests from the I18N package
- Moving report stylesheets to buildscripts/phing - Added a build/dist target for both standard distribution and PEAR package to build.xml
Diffstat (limited to 'tests/unit/I18N/core/NumberFormatInfoTest.php')
-rw-r--r--tests/unit/I18N/core/NumberFormatInfoTest.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/unit/I18N/core/NumberFormatInfoTest.php b/tests/unit/I18N/core/NumberFormatInfoTest.php
new file mode 100644
index 00000000..a3b6d05a
--- /dev/null
+++ b/tests/unit/I18N/core/NumberFormatInfoTest.php
@@ -0,0 +1,88 @@
+<?php
+require_once dirname(__FILE__).'/../../phpunit2.php';
+
+//NOTE: This page require UTF-8 aware editors
+Prado::using('System.I18N.core.NumberFormatInfo');
+
+/**
+ * @package System.I18N.core
+ */
+class NumberFormatInfoTest extends PHPUnit2_Framework_TestCase {
+
+ function testCurrencyPatterns() {
+ $numberInfo = NumberFormatInfo::getCurrencyInstance();
+
+ //there should be 2 decimal places.
+ $this->assertEquals($numberInfo->DecimalDigits,2);
+ $this->assertEquals($numberInfo->DecimalSeparator,'.');
+ $this->assertEquals($numberInfo->GroupSeparator,',');
+
+ //there should be only 1 grouping of size 3
+ $groupsize = array(3,false);
+ $this->assertEquals($numberInfo->GroupSizes, $groupsize);
+
+ //the default negative pattern prefix and postfix
+ $negPattern = array('-¤','');
+ $this->assertEquals($numberInfo->NegativePattern, $negPattern);
+
+ //the default positive pattern prefix and postfix
+ $negPattern = array('¤','');
+ $this->assertEquals($numberInfo->PositivePattern, $negPattern);
+
+ //the default currency symbol
+ $this->assertEquals($numberInfo->CurrencySymbol, 'US$');
+ $this->assertEquals($numberInfo->getCurrencySymbol('JPY'), '¥');
+ $this->assertEquals($numberInfo->NegativeInfinitySymbol, '-∞');
+ $this->assertEquals($numberInfo->PositiveInfinitySymbol, '+∞');
+ $this->assertEquals($numberInfo->NegativeSign, '-');
+ $this->assertEquals($numberInfo->PositiveSign, '+');
+ $this->assertEquals($numberInfo->NaNSymbol, '�');
+ $this->assertEquals($numberInfo->PercentSymbol, '%');
+ $this->assertEquals($numberInfo->PerMilleSymbol, '‰');
+ }
+
+ function testPatternsSet() {
+ $numberInfo = NumberFormatInfo::getInstance();
+
+ $numberInfo->DecimalDigits = 0;
+ $this->assertEquals($numberInfo->DecimalDigits,0);
+
+ $numberInfo->DecimalSeparator = ',';
+ $this->assertEquals($numberInfo->DecimalSeparator,',');
+
+ $numberInfo->GroupSeparator = ' ';
+ $this->assertEquals($numberInfo->GroupSeparator,' ');
+
+ $numberInfo->GroupSizes = array(2,3);
+ $groupsize = array(2,3);
+ $this->assertEquals($numberInfo->GroupSizes, $groupsize);
+
+ $numberInfo->NegativePattern = array('-$$','.');
+ $negPattern = array('-$$','.');
+ $this->assertEquals($numberInfo->NegativePattern, $negPattern);
+
+ $numberInfo->PositivePattern = array('YY','.');
+ $negPattern = array('YY','.');
+ $this->assertEquals($numberInfo->PositivePattern, $negPattern);
+
+ //the default CurrencySymbol symbol
+ $numberInfo->CurrencySymbol = '$$$';
+ $this->assertEquals($numberInfo->CurrencySymbol, '$$$');
+ }
+
+ function testLocalizedPatterns() {
+ $fr = NumberFormatInfo::getInstance('fr');
+ $de = NumberFormatInfo::getInstance('de');
+ $en = NumberFormatInfo::getInstance('en_US');
+
+ $this->assertEquals($fr->DecimalSeparator, ',');
+ $this->assertEquals($de->DecimalSeparator, ',');
+ $this->assertEquals($en->DecimalSeparator, '.');
+
+ $this->assertEquals($fr->GroupSeparator, ' ');
+ $this->assertEquals($de->GroupSeparator, '.');
+ $this->assertEquals($en->GroupSeparator, ',');
+ }
+}
+
+?> \ No newline at end of file