]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_xdrlib.py
1 from test
import test_support
6 class XDRTest(unittest
.TestCase
):
12 a
= ['what', 'is', 'hapnin', 'doctor']
23 p
.pack_list(range(5), p
.pack_uint
)
24 p
.pack_array(a
, p
.pack_string
)
28 up
= xdrlib
.Unpacker(data
)
30 self
.assertEqual(up
.get_position(), 0)
32 self
.assertEqual(up
.unpack_int(), 42)
33 self
.assertEqual(up
.unpack_int(), -17)
34 self
.assertEqual(up
.unpack_uint(), 9)
35 self
.assertTrue(up
.unpack_bool() is True)
38 pos
= up
.get_position()
39 self
.assertTrue(up
.unpack_bool() is False)
41 # rewind and unpack again
43 self
.assertTrue(up
.unpack_bool() is False)
45 self
.assertEqual(up
.unpack_uhyper(), 45L)
46 self
.assertAlmostEqual(up
.unpack_float(), 1.9)
47 self
.assertAlmostEqual(up
.unpack_double(), 1.9)
48 self
.assertEqual(up
.unpack_string(), s
)
49 self
.assertEqual(up
.unpack_list(up
.unpack_uint
), range(5))
50 self
.assertEqual(up
.unpack_array(up
.unpack_string
), a
)
52 self
.assertRaises(EOFError, up
.unpack_uint
)
55 test_support
.run_unittest(XDRTest
)
57 if __name__
== "__main__":