ia64/xen-unstable

changeset 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 377b64f085d0
children 6ef7386f7370
files tools/python/xen/xend/tests/test_uuid.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/python/xen/xend/tests/test_uuid.py	Tue Oct 18 18:01:14 2005 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +import unittest
     1.5 +
     1.6 +from xen.xend import uuid
     1.7 +
     1.8 +
     1.9 +class test_uuid(unittest.TestCase):
    1.10 +
    1.11 +    def testStringRoundtrip(self):
    1.12 +        def t(inp):
    1.13 +            self.assertEqual(uuid.fromString(uuid.toString(inp)), inp)
    1.14 +
    1.15 +        t(uuid.create())
    1.16 +        t(uuid.create())
    1.17 +        t(uuid.create())
    1.18 +        t(uuid.create())
    1.19 +        t(uuid.create())
    1.20 +
    1.21 +
    1.22 +    def testToFromString(self):
    1.23 +        def t(inp, expected):
    1.24 +            self.assertEqual(uuid.toString(inp), expected)
    1.25 +            self.assertEqual(uuid.fromString(expected), inp)
    1.26 +
    1.27 +        t([0 for i in range(0, 16)], "00000000-0000-0000-0000-000000000000")
    1.28 +        t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
    1.29 +           196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
    1.30 +
    1.31 +
    1.32 +def test_suite():
    1.33 +    return unittest.makeSuite(test_uuid)