ia64/xen-unstable

annotate tools/python/xen/xend/tests/test_uuid.py @ 7427:c24fae1cd39d

Added uuid unit test.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Oct 18 18:01:14 2005 +0100 (2005-10-18)
parents
children b7790c2874c4
rev   line source
emellor@7427 1 import unittest
emellor@7427 2
emellor@7427 3 from xen.xend import uuid
emellor@7427 4
emellor@7427 5
emellor@7427 6 class test_uuid(unittest.TestCase):
emellor@7427 7
emellor@7427 8 def testStringRoundtrip(self):
emellor@7427 9 def t(inp):
emellor@7427 10 self.assertEqual(uuid.fromString(uuid.toString(inp)), inp)
emellor@7427 11
emellor@7427 12 t(uuid.create())
emellor@7427 13 t(uuid.create())
emellor@7427 14 t(uuid.create())
emellor@7427 15 t(uuid.create())
emellor@7427 16 t(uuid.create())
emellor@7427 17
emellor@7427 18
emellor@7427 19 def testToFromString(self):
emellor@7427 20 def t(inp, expected):
emellor@7427 21 self.assertEqual(uuid.toString(inp), expected)
emellor@7427 22 self.assertEqual(uuid.fromString(expected), inp)
emellor@7427 23
emellor@7427 24 t([0 for i in range(0, 16)], "00000000-0000-0000-0000-000000000000")
emellor@7427 25 t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
emellor@7427 26 196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
emellor@7427 27
emellor@7427 28
emellor@7427 29 def test_suite():
emellor@7427 30 return unittest.makeSuite(test_uuid)