Adding tests to dbo_postgres for localized floats. Refs #1029

This commit is contained in:
mark_story 2010-08-21 00:39:45 -04:00
parent afc05c1e05
commit eb96d8acfb

View file

@ -352,7 +352,7 @@ class DboPostgresTest extends CakeTestCase {
* @return void * @return void
*/ */
function testValueQuoting() { 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('1,2', 'float'), "'1,2'");
$this->assertEqual($this->db2->value('0', 'integer'), "'0'"); $this->assertEqual($this->db2->value('0', 'integer'), "'0'");
@ -378,6 +378,24 @@ class DboPostgresTest extends CakeTestCase {
$this->assertEqual($this->db2->value(array()), "NULL"); $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. * test that date and time columns do not generate errors with null and nullish values.
* *