From f8fe7d47cc5adb3c9e1901082c65c8766441f09e Mon Sep 17 00:00:00 2001
From: wei <>
Date: Tue, 1 Aug 2006 01:25:57 +0000
Subject: Fixed #285

---
 .../tickets/protected/pages/Ticket285.page         |  7 ++++++
 .../tickets/tests/Ticket285TestCase.php            | 12 +++++++++++
 tests/unit/I18N/core/NumberFormatTest.php          | 25 ++++++++++++++++++++--
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket285.page
 create mode 100644 tests/FunctionalTests/tickets/tests/Ticket285TestCase.php

(limited to 'tests')

diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket285.page b/tests/FunctionalTests/tickets/protected/pages/Ticket285.page
new file mode 100644
index 00000000..9aeb37e9
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket285.page
@@ -0,0 +1,7 @@
+<com:TContent ID="Content">
+
+<com:System.I18N.TNumberFormat Value="349.999" Pattern="#.00" />
+
+<com:System.I18N.TNumberFormat Value="349.99" Pattern="#.00" />
+
+</com:TContent>
\ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php
new file mode 100644
index 00000000..cd681c58
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php
@@ -0,0 +1,12 @@
+<?php
+
+class Ticket285TestCase extends SeleniumTestCase
+{
+	function test()
+	{
+		$this->open('tickets/index.php?page=Ticket285');
+		$this->assertTextPresent('350.00');
+		$this->assertTextPresent('349.99');
+	}
+}
+?>
\ No newline at end of file
diff --git a/tests/unit/I18N/core/NumberFormatTest.php b/tests/unit/I18N/core/NumberFormatTest.php
index af6a06ca..e136058e 100644
--- a/tests/unit/I18N/core/NumberFormatTest.php
+++ b/tests/unit/I18N/core/NumberFormatTest.php
@@ -12,6 +12,7 @@ class NumberFormatTest extends PHPUnit2_Framework_TestCase {
     $formatter = new NumberFormat();
     $number = '123456789.125156';
     $wanted = '123,456,789.125156';
+
     $this->assertEquals($wanted, $formatter->format($number));
     
     //currency
@@ -87,8 +88,7 @@ class NumberFormatTest extends PHPUnit2_Framework_TestCase {
     $pattern = '0000';
     $wanted = '0005';
     
-    //this should fail!!!
-    $this->assertNotEquals($wanted, $formatter->format($number, $pattern));
+    $this->assertEquals($wanted, $formatter->format($number, $pattern));
   }
   
   function testFormatWithANegativeValue() {
@@ -105,7 +105,28 @@ class NumberFormatTest extends PHPUnit2_Framework_TestCase {
     $expected = "10E";
     $this->assertEquals('10E', $formatter->format($number, 'e'));
   }
+  
+  function testRounding()
+  {
+  	  $formatter = new NumberFormat();
+  	  
+  	  $number = 349.999;
+  	  $pattern = '#.00';
+  	  $expected = '350.00';
+  	  
+  	  $this->assertEquals($expected, $formatter->format($number, $pattern));
+  }
 
+  function testRounding2()
+  {
+  	  $formatter = new NumberFormat();
+  	  
+  	  $number = 349.99;
+  	  $pattern = '#.00';
+  	  $expected = '349.99';
+  	  
+  	  $this->assertEquals($expected, $formatter->format($number, $pattern));
+  }
 }
 
 ?>
\ No newline at end of file
-- 
cgit v1.2.3