A couple of attribute python unit tests
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu, 17 Jul 2008 17:57:18 +0100
changeset 3431 ccf8108ce6d7
parent 3429 2658cf81a5cd
child 3432 2dd172a2bc64
A couple of attribute python unit tests
utils/python-unit-tests.py
--- a/utils/python-unit-tests.py	Wed Jul 16 17:44:42 2008 +0100
+++ b/utils/python-unit-tests.py	Thu Jul 17 17:57:18 2008 +0100
@@ -78,7 +78,35 @@
         ns3.Simulator.Run()
         self.assert_(self._received_packet is not None)
         self.assertEqual(self._received_packet.GetSize(), 19)
+
+
+    def testAttributes(self):
+        ##
+        ## Yes, I know, the GetAttribute interface for Python is
+        ## horrible, we should fix this soon, I hope.
+        ##
+        queue = ns3.DropTailQueue()
+
+        queue.SetAttribute("MaxPackets", ns3.UintegerValue(123456))
+
+        limit = ns3.UintegerValue()
+        queue.GetAttribute("MaxPackets", limit)
+        self.assertEqual(limit.Get(), 123456)
+
+        ## -- object pointer values
+        mobility = ns3.RandomWaypointMobilityModel()
+        ptr = ns3.PointerValue()
+        mobility.GetAttribute("Position", ptr)
+        self.assertEqual(ptr.GetObject(), None)
         
+        pos = ns3.ListPositionAllocator()
+        mobility.SetAttribute("Position", ns3.PointerValue(pos))
+
+        ptr = ns3.PointerValue()
+        mobility.GetAttribute("Position", ptr)
+        self.assert_(ptr.GetObject() is not None)
+        
+
 
 if __name__ == '__main__':
     unittest.main()