Skip to content
Permalink
Browse files

MDL-27325 Adding some extreme, but 32bits safe, float tests

  • Loading branch information...
stronk7 committed May 5, 2011
1 parent 0c4c6d4 commit 86f456d8f0834e03b5bf6b9b9dd2ae41574cd164
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/dml/simpletest/testdml.php
@@ -1816,6 +1816,10 @@ public function test_insert_record() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 1.0));
@@ -1826,6 +1830,10 @@ public function test_insert_record() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
}
public function test_import_record() {
@@ -2208,6 +2216,10 @@ public function test_update_record() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 'X'));
@@ -2219,6 +2231,10 @@ public function test_update_record() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
}
public function test_set_field() {
@@ -2294,6 +2310,10 @@ public function test_set_field() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e-5, array('id' => $id));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e-300, array('id' => $id));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e300, array('id' => $id));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 'X'));
@@ -2305,6 +2325,10 @@ public function test_set_field() {
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e-5, array('id' => $id));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e-300, array('id' => $id));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e300, array('id' => $id));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
// Note: All the nulls, booleans, empties, quoted and backslashes tests
// go to set_field_select() because set_field() is just one wrapper over it

0 comments on commit 86f456d

Please sign in to comment.
You can’t perform that action at this time.