Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 86f456d8f0834e03b5bf6b9b9dd2ae41574cd164 1 parent 0c4c6d4
Eloy Lafuente (stronk7) authored May 05, 2011

Showing 1 changed file with 24 additions and 0 deletions. Show diff stats Hide diff stats

  1. 24  lib/dml/simpletest/testdml.php
24  lib/dml/simpletest/testdml.php
@@ -1816,6 +1816,10 @@ public function test_insert_record() {
1816 1816
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
1817 1817
         $id = $DB->insert_record($tablename, array('onechar' => 1e-5));
1818 1818
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  1819
+        $id = $DB->insert_record($tablename, array('onechar' => 1e-300));
  1820
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  1821
+        $id = $DB->insert_record($tablename, array('onechar' => 1e300));
  1822
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
1819 1823
 
1820 1824
         // Test saving a float in a TEXT column, and reading it back.
1821 1825
         $id = $DB->insert_record($tablename, array('onetext' => 1.0));
@@ -1826,6 +1830,10 @@ public function test_insert_record() {
1826 1830
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
1827 1831
         $id = $DB->insert_record($tablename, array('onetext' => 1e-5));
1828 1832
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  1833
+        $id = $DB->insert_record($tablename, array('onetext' => 1e-300));
  1834
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  1835
+        $id = $DB->insert_record($tablename, array('onetext' => 1e300));
  1836
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
1829 1837
     }
1830 1838
 
1831 1839
     public function test_import_record() {
@@ -2208,6 +2216,10 @@ public function test_update_record() {
2208 2216
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
2209 2217
         $DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-5));
2210 2218
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  2219
+        $DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-300));
  2220
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  2221
+        $DB->update_record($tablename, array('id' => $id, 'onechar' => 1e300));
  2222
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
2211 2223
 
2212 2224
         // Test saving a float in a TEXT column, and reading it back.
2213 2225
         $id = $DB->insert_record($tablename, array('onetext' => 'X'));
@@ -2219,6 +2231,10 @@ public function test_update_record() {
2219 2231
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
2220 2232
         $DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-5));
2221 2233
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  2234
+        $DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-300));
  2235
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  2236
+        $DB->update_record($tablename, array('id' => $id, 'onetext' => 1e300));
  2237
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
2222 2238
     }
2223 2239
 
2224 2240
     public function test_set_field() {
@@ -2294,6 +2310,10 @@ public function test_set_field() {
2294 2310
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
2295 2311
         $DB->set_field($tablename, 'onechar', 1e-5, array('id' => $id));
2296 2312
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  2313
+        $DB->set_field($tablename, 'onechar', 1e-300, array('id' => $id));
  2314
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
  2315
+        $DB->set_field($tablename, 'onechar', 1e300, array('id' => $id));
  2316
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
2297 2317
 
2298 2318
         // Test saving a float in a TEXT column, and reading it back.
2299 2319
         $id = $DB->insert_record($tablename, array('onetext' => 'X'));
@@ -2305,6 +2325,10 @@ public function test_set_field() {
2305 2325
         $this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
2306 2326
         $DB->set_field($tablename, 'onetext', 1e-5, array('id' => $id));
2307 2327
         $this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  2328
+        $DB->set_field($tablename, 'onetext', 1e-300, array('id' => $id));
  2329
+        $this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
  2330
+        $DB->set_field($tablename, 'onetext', 1e300, array('id' => $id));
  2331
+        $this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
2308 2332
 
2309 2333
         // Note: All the nulls, booleans, empties, quoted and backslashes tests
2310 2334
         // go to set_field_select() because set_field() is just one wrapper over it

0 notes on commit 86f456d

Please sign in to comment.
Something went wrong with that request. Please try again.