summaryrefslogtreecommitdiff
path: root/tests/unit/I18N/TNumberFormatTest.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/TNumberFormatTest.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/TNumberFormatTest.php')
-rw-r--r--tests/unit/I18N/TNumberFormatTest.php103
1 files changed, 0 insertions, 103 deletions
diff --git a/tests/unit/I18N/TNumberFormatTest.php b/tests/unit/I18N/TNumberFormatTest.php
deleted file mode 100644
index 18e5f3ff..00000000
--- a/tests/unit/I18N/TNumberFormatTest.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-require_once dirname(__FILE__).'/../phpunit2.php';
-
-//NOTE: This page require UTF-8 aware editors
-Prado::using('System.I18N.core.NumberFormat');
-
-/**
- * @package System.I18N
- */
-class TNumberFormatTest extends PHPUnit2_Framework_TestCase {
- function testDefaultFormats() {
- $formatter = new NumberFormat();
- $number = '123456789.125156';
- $wanted = '123,456,789.125156';
- $this->assertEquals($wanted, $formatter->format($number));
-
- //currency
- $wanted = 'US$123,456,789.13';
- $this->assertEquals($wanted, $formatter->format($number,'c'));
- }
-
- function testLocalizedCurrencyFormats() {
- $fr = new NumberFormat('fr');
- $de = new NumberFormat('de');
- $ja = new NumberFormat('ja_JP');
-
- $number = '123456789.125156';
-
- //french
- $wanted = '123 456 789,13 F';
- $this->assertEquals($wanted, $fr->format($number,'c','FRF'));
-
- //german
- $wanted = 'DES 123.456.789,13';
- $this->assertEquals($wanted, $de->format($number,'c','DES'));
-
- //japanese
- $wanted = '¥123,456,789';
- $this->assertEquals($wanted, $ja->format($number,'c','JPY'));
-
- //custom/unkown currency
- $wanted = 'DLL123,456,789';
- $this->assertEquals($wanted, $ja->format($number,'c','DLL'));
- }
-
- function testCustomFormat() {
- $formatter = new NumberFormat();
- $number = '123456789.125156';
-
- //primay and secondary grouping test
- $pattern = '#,###,##.###';
- $wanted = '1,234,567,89.125156';
- $this->assertEquals($wanted, $formatter->format($number, $pattern));
-
- //4 digits grouping test
- $pattern = '#,####.###';
- $wanted = '1,2345,6789.125156';
- $this->assertEquals($wanted, $formatter->format($number, $pattern));
-
- //custom percentage
- $pattern = '#,###.00%';
- $wanted = '123,456,789.13%';
- $this->assertEquals($wanted, $formatter->format($number, $pattern));
- }
-
- function testPercentageFormat() {
- $formatter = new NumberFormat();
- $number = '0.125156';
- $wanted = '12%';
- $this->assertEquals($wanted, $formatter->format($number, 'p'));
- }
-
- function testQuotes() {
- $formatter = new NumberFormat();
- $number = '123456789.125156';
-
- $pattern = "# o'clock";
- $wanted = "123456789 o'clock";
- $this->assertEquals($wanted, $formatter->format($number, $pattern));
-
- }
-
- function testPadding() {
- $formatter = new NumberFormat();
- $number = '5';
-
- $pattern = '0000';
- $wanted = '0005';
-
- //this should fail!!!
- $this->assertNotEquals($wanted, $formatter->format($number, $pattern));
- }
-
- function testNegativeValue() {
- $formatter = new NumberFormat();
- $number = "-1.2";
-
- $wanted = "-1.2";
- $this->assertEquals($wanted, $formatter->format($number));
- }
-}
-
-?> \ No newline at end of file