BIND 10 master, updated. ddde1f3034cb004bde11a8c1ba41944a2ce58fff [master] Fix floating point issue in unit test

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jan 28 10:35:08 UTC 2013


The branch, master has been updated
       via  ddde1f3034cb004bde11a8c1ba41944a2ce58fff (commit)
      from  3d4f3cd903294e03bafbf37963051fdcf2233cae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ddde1f3034cb004bde11a8c1ba41944a2ce58fff
Author: Jelte Jansen <jelte at isc.org>
Date:   Mon Jan 28 11:34:39 2013 +0100

    [master] Fix floating point issue in unit test
    
    reviewed on jabber (muks)

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/cc/tests/message_test.py |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/cc/tests/message_test.py b/src/lib/python/isc/cc/tests/message_test.py
index c417068..17f034d 100644
--- a/src/lib/python/isc/cc/tests/message_test.py
+++ b/src/lib/python/isc/cc/tests/message_test.py
@@ -27,20 +27,27 @@ class MessageTest(unittest.TestCase):
         self.msg1_str = "{\"just\": [\"an\", \"arbitrary\", \"structure\"]}";
         self.msg1_wire = self.msg1_str.encode()
 
-        self.msg2 = { "aaa": [ 1, 1.1, True, False, None ] }
-        self.msg2_str = "{\"aaa\": [1, 1.1, true, false, null]}";
+        self.msg2 = { "aaa": [ 1, True, False, None ] }
+        self.msg2_str = "{\"aaa\": [1, true, false, null]}";
         self.msg2_wire = self.msg2_str.encode()
 
         self.msg3 = { "aaa": [ 1, 1.1, True, False, "string\n" ] }
         self.msg3_str = "{\"aaa\": [1, 1.1, true, false, \"string\n\" ]}";
         self.msg3_wire = self.msg3_str.encode()
 
+        # Due to the inherent impreciseness of floating point values,
+        # we test this one separately (with AlmostEqual)
+        self.msg_float = 1.1
+        self.msg_float_str = "1.1";
+        self.msg_float_wire = self.msg_float_str.encode()
+
     def test_encode_json(self):
         self.assertEqual(self.msg1_wire, isc.cc.message.to_wire(self.msg1))
         self.assertEqual(self.msg2_wire, isc.cc.message.to_wire(self.msg2))
-
+        self.assertAlmostEqual(float(self.msg_float_wire),
+                               float(isc.cc.message.to_wire(self.msg_float)))
         self.assertRaises(TypeError, isc.cc.message.to_wire, NotImplemented)
-        
+
     def test_decode_json(self):
         self.assertEqual(self.msg1, isc.cc.message.from_wire(self.msg1_wire))
         self.assertEqual(self.msg2, isc.cc.message.from_wire(self.msg2_wire))



More information about the bind10-changes mailing list