Permalink
Browse files

Adding tests to dbo_postgres for localized floats. Refs #1029

  • Loading branch information...
markstory committed Aug 21, 2010
1 parent afc05c1 commit eb96d8acfbe6c31230fb28f21110aaec5de57eaf
Showing with 19 additions and 1 deletion.
  1. +19 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -352,7 +352,7 @@ function testColumnParsing() {
* @return void
*/
function testValueQuoting() {
- $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.2'");
+ $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'");
$this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'");
$this->assertEqual($this->db2->value('0', 'integer'), "'0'");
@@ -378,6 +378,24 @@ function testValueQuoting() {
$this->assertEqual($this->db2->value(array()), "NULL");
}
+/**
+ * test that localized floats don't cause trouble.
+ *
+ * @return void
+ */
+ function testLocalizedFloats() {
+ $restore = setlocale(LC_ALL, null);
+ setlocale(LC_ALL, 'de_DE');
+
+ $result = $this->db->value(3.141593, 'float');
+ $this->assertEqual((string)$result, "'3.141593'");
+
+ $result = $this->db->value(3.14);
+ $this->assertEqual((string)$result, "'3.140000'");
+
+ setlocale(LC_ALL, $restore);
+ }
+
/**
* test that date and time columns do not generate errors with null and nullish values.
*

0 comments on commit eb96d8a

Please sign in to comment.