<s> from test import test_support <EOL> import unittest <EOL> import xdrlib <EOL> class XDRTest ( unittest . TestCase ) : <EOL> def test_xdr ( self ) : <EOL> p = xdrlib . Packer ( ) <EOL> s = '<STR_LIT>' <EOL> a = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> p . pack_int ( <NUM_LIT> ) <EOL> p . pack_int ( - <NUM_LIT> ) <EOL> p . pack_uint ( <NUM_LIT:9> ) <EOL> p . pack_bool ( True ) <EOL> p . pack_bool ( False ) <EOL> p . pack_uhyper ( <NUM_LIT> L ) <EOL> p . pack_float ( <NUM_LIT> ) <EOL> p . pack_double ( <NUM_LIT> ) <EOL> p . pack_string ( s ) <EOL> p . pack_list ( range ( <NUM_LIT:5> ) , p . pack_uint ) <EOL> p . pack_array ( a , p . pack_string ) <EOL> data = p . get_buffer ( ) <EOL> up = xdrlib . Unpacker ( data ) <EOL> self . assertEqual ( up . get_position ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( up . unpack_int ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( up . unpack_int ( ) , - <NUM_LIT> ) <EOL> self . assertEqual ( up . unpack_uint ( ) , <NUM_LIT:9> ) <EOL> self . assertTrue ( up . unpack_bool ( ) is True ) <EOL> pos = up . get_position ( ) <EOL> self . assertTrue ( up . unpack_bool ( ) is False ) <EOL> up . set_position ( pos ) <EOL> self . assertTrue ( up . unpack_bool ( ) is False ) <EOL> self . assertEqual ( up . unpack_uhyper ( ) , <NUM_LIT> L ) <EOL> self . assertAlmostEqual ( up . unpack_float ( ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( up . unpack_double ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( up . unpack_string ( ) , s ) <EOL> self . assertEqual ( up . unpack_list ( up . unpack_uint ) , range ( <NUM_LIT:5> ) ) <EOL> self . assertEqual ( up . unpack_array ( up . unpack_string ) , a ) <EOL> up . done ( ) <EOL> self . assertRaises ( EOFError , up . unpack_uint ) <EOL> class ConversionErrorTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . packer = xdrlib . Packer ( ) <EOL> def assertRaisesConversion ( self , * args ) : <EOL> self . assertRaises ( xdrlib . ConversionError , * args ) <EOL> def test_pack_int ( self ) : <EOL> self . assertRaisesConversion ( self . packer . pack_int , '<STR_LIT:string>' ) <EOL> def test_pack_uint ( self ) : <EOL> self . assertRaisesConversion ( self . packer . pack_uint , '<STR_LIT:string>' ) <EOL> def test_float ( self ) : <EOL> self . assertRaisesConversion ( self . packer . pack_float , '<STR_LIT:string>' ) <EOL> def test_double ( self ) : <EOL> self . assertRaisesConversion ( self . packer . pack_double , '<STR_LIT:string>' ) <EOL> def test_uhyper ( self ) : <EOL> self . assertRaisesConversion ( self . packer . pack_uhyper , '<STR_LIT:string>' ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( XDRTest ) <EOL> test_support . run_unittest ( ConversionErrorTest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
