#QUALITY by exept
authorClaus Gittinger <cg@exept.de>
Sat, 23 Nov 2019 19:39:16 +0100
changeset 2417 6821e4990968
parent 2416 0c9cb936ffe1
child 2418 187b80d0dd61
#QUALITY by exept class: RegressionTests::QDoubleTests added: #test_09_truncating changed: #test99_misc #test_01_instance_creation #test_02_addition
RegressionTests__QDoubleTests.st
--- a/RegressionTests__QDoubleTests.st	Fri Nov 22 04:43:49 2019 +0100
+++ b/RegressionTests__QDoubleTests.st	Sat Nov 23 19:39:16 2019 +0100
@@ -32,7 +32,7 @@
 !QDoubleTests methodsFor:'tests'!
 
 test99_misc
-     self skip:'unfinished work in progress'.
+     "/ self skip:'unfinished work in progress'.
      
      self assert:( 1 asQDouble / (3 factorial) - (QDouble invFact at:1) ) = 0.0. 
      self assert:( 1 asQDouble / (4 factorial) - (QDouble invFact at:2) ) = 0.0. 
@@ -63,6 +63,18 @@
     self assert:(q d2 = 0.0).
     self assert:(q d3 = 0.0).
 
+    q := QDouble fromInteger:1.
+    self assert:(q d0 = 1.0).
+    self assert:(q d1 = 0.0).
+    self assert:(q d2 = 0.0).
+    self assert:(q d3 = 0.0).
+
+    q := 1 asQDouble.
+    self assert:(q d0 = 1.0).
+    self assert:(q d1 = 0.0).
+    self assert:(q d2 = 0.0).
+    self assert:(q d3 = 0.0).
+
     q := 1.0 asQDouble.
     self assert:(q d0 = 1.0).
     self assert:(q d1 = 0.0).
@@ -156,6 +168,8 @@
     self assert:(sum_q d2 = 1e40).
     self assert:(sum_q d3 = 1.0).
 
+    '%.60f' printf:{QDouble pi}
+
     "
      self run:#test_02_addition
      self new test_02_addition
@@ -537,6 +551,25 @@
 
     "Created: / 20-06-2017 / 07:51:50 / cg"
     "Modified: / 05-06-2019 / 20:18:48 / Claus Gittinger"
+!
+
+test_09_truncating
+    self assert:(1.0 asQDouble truncated = 1.0 asQDouble).
+    self assert:(1.0 asQDouble truncated = 1.0).
+
+    self assert:(1.1 asQDouble truncated = 1.0 asQDouble).
+    self assert:(1.1 asQDouble truncated = 1.0).
+
+    self assert:(1.999 asQDouble truncated = 1.0 asQDouble).
+    self assert:(1.999 asQDouble truncated = 1.0).
+
+    self assert:(-1.999 asQDouble truncated = -2.0 asQDouble).
+    self assert:(-1.999 asQDouble truncated = -2.0).
+
+    "
+     self run:#test_09_truncating
+     self new test_09_truncating
+    "
 ! !
 
 !QDoubleTests class methodsFor:'documentation'!