<s> import sys <EOL> import unittest <EOL> import pyhsm <EOL> import test_common <EOL> class TestUtil ( test_common . YHSM_TestCase ) : <EOL> def setUp ( self ) : <EOL> test_common . YHSM_TestCase . setUp ( self ) <EOL> def test_hexdump ( self ) : <EOL> """<STR_LIT>""" <EOL> data1 = '<STR_LIT>' . join ( [ chr ( x ) for x in xrange ( <NUM_LIT:8> ) ] ) <EOL> self . assertEquals ( '<STR_LIT>' , pyhsm . util . hexdump ( data1 ) ) <EOL> data2 = '<STR_LIT>' . join ( [ chr ( x ) for x in xrange ( <NUM_LIT:64> ) ] ) <EOL> self . assertEquals ( <NUM_LIT> , len ( pyhsm . util . hexdump ( data2 ) ) ) <EOL> self . assertEquals ( '<STR_LIT>' , pyhsm . util . hexdump ( '<STR_LIT>' ) ) <EOL> def test_response_validation ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( pyhsm . exception . YHSM_Error , pyhsm . util . validate_cmd_response_str , '<STR_LIT:test>' , '<STR_LIT:abc>' , '<STR_LIT>' , hex_encode = True ) <EOL> self . assertRaises ( pyhsm . exception . YHSM_Error , pyhsm . util . validate_cmd_response_str , '<STR_LIT:test>' , '<STR_LIT:abc>' , '<STR_LIT>' , hex_encode = False ) <EOL> def test_input_validate_str ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( pyhsm . exception . YHSM_WrongInputType , pyhsm . util . input_validate_str , <NUM_LIT:0> , '<STR_LIT:foo>' , exact_len = <NUM_LIT:5> ) <EOL> self . assertRaises ( pyhsm . exception . YHSM_InputTooLong , pyhsm . util . input_validate_str , '<STR_LIT>' , '<STR_LIT:foo>' , max_len = <NUM_LIT:3> ) <EOL> self . assertEquals ( '<STR_LIT>' , pyhsm . util . input_validate_str ( '<STR_LIT>' , '<STR_LIT:foo>' , max_len = <NUM_LIT:4> ) ) <EOL> self . assertEquals ( '<STR_LIT>' , pyhsm . util . input_validate_str ( '<STR_LIT>' , '<STR_LIT:foo>' , max_len = <NUM_LIT> ) ) <EOL> self . assertRaises ( pyhsm . exception . YHSM_WrongInputSize , pyhsm . util . input_validate_str , '<STR_LIT>' , '<STR_LIT:foo>' , exact_len = <NUM_LIT:5> ) <EOL> self . assertEquals ( '<STR_LIT>' , pyhsm . util . input_validate_str ( '<STR_LIT>' , '<STR_LIT:foo>' , exact_len = <NUM_LIT:4> ) ) </s>
