<s> import unittest <EOL> from hazelcast . config import SerializationConfig , INTEGER_TYPE <EOL> from hazelcast . exception import HazelcastSerializationError <EOL> from hazelcast . serialization . serialization_const import CONSTANT_TYPE_BYTE , CONSTANT_TYPE_SHORT , CONSTANT_TYPE_INTEGER , CONSTANT_TYPE_LONG <EOL> from hazelcast . serialization . service import SerializationServiceV1 <EOL> byte_val = <NUM_LIT> <EOL> short_val = <NUM_LIT> <EOL> int_val = <NUM_LIT> <EOL> long_val = <NUM_LIT> <EOL> big_int = <NUM_LIT> <EOL> class IntegerTestCase ( unittest . TestCase ) : <EOL> def test_dynamic_case ( self ) : <EOL> config = SerializationConfig ( ) <EOL> config . default_integer_type = INTEGER_TYPE . VAR <EOL> service = SerializationServiceV1 ( serialization_config = config ) <EOL> d1 = service . to_data ( byte_val ) <EOL> d2 = service . to_data ( short_val ) <EOL> d3 = service . to_data ( int_val ) <EOL> d4 = service . to_data ( long_val ) <EOL> v1 = service . to_object ( d1 ) <EOL> v2 = service . to_object ( d2 ) <EOL> v3 = service . to_object ( d3 ) <EOL> v4 = service . to_object ( d4 ) <EOL> self . assertEqual ( d1 . get_type ( ) , CONSTANT_TYPE_BYTE ) <EOL> self . assertEqual ( d2 . get_type ( ) , CONSTANT_TYPE_SHORT ) <EOL> self . assertEqual ( d3 . get_type ( ) , CONSTANT_TYPE_INTEGER ) <EOL> self . assertEqual ( d4 . get_type ( ) , CONSTANT_TYPE_LONG ) <EOL> self . assertEqual ( v1 , byte_val ) <EOL> self . assertEqual ( v2 , short_val ) <EOL> self . assertEqual ( v3 , int_val ) <EOL> self . assertEqual ( v4 , long_val ) <EOL> def test_byte_case ( self ) : <EOL> config = SerializationConfig ( ) <EOL> config . default_integer_type = INTEGER_TYPE . BYTE <EOL> service = SerializationServiceV1 ( serialization_config = config ) <EOL> d1 = service . to_data ( byte_val ) <EOL> v1 = service . to_object ( d1 ) <EOL> self . assertEqual ( d1 . get_type ( ) , CONSTANT_TYPE_BYTE ) <EOL> self . assertEqual ( v1 , byte_val ) <EOL> with self . assertRaises ( HazelcastSerializationError ) : <EOL> service . to_data ( big_int ) <EOL> def test_short_case ( self ) : <EOL> config = SerializationConfig ( ) <EOL> config . default_integer_type = INTEGER_TYPE . SHORT <EOL> service = SerializationServiceV1 ( serialization_config = config ) <EOL> d1 = service . to_data ( byte_val ) <EOL> d2 = service . to_data ( short_val ) <EOL> v1 = service . to_object ( d1 ) <EOL> v2 = service . to_object ( d2 ) <EOL> self . assertEqual ( d1 . get_type ( ) , CONSTANT_TYPE_SHORT ) <EOL> self . assertEqual ( d2 . get_type ( ) , CONSTANT_TYPE_SHORT ) <EOL> self . assertEqual ( v1 , byte_val ) <EOL> self . assertEqual ( v2 , short_val ) <EOL> with self . assertRaises ( HazelcastSerializationError ) : <EOL> service . to_data ( big_int ) <EOL> def test_int_case ( self ) : <EOL> config = SerializationConfig ( ) <EOL> config . default_integer_type = INTEGER_TYPE . INT <EOL> service = SerializationServiceV1 ( serialization_config = config ) <EOL> d1 = service . to_data ( byte_val ) <EOL> d2 = service . to_data ( short_val ) <EOL> d3 = service . to_data ( int_val ) <EOL> v1 = service . to_object ( d1 ) <EOL> v2 = service . to_object ( d2 ) <EOL> v3 = service . to_object ( d3 ) <EOL> self . assertEqual ( d1 . get_type ( ) , CONSTANT_TYPE_INTEGER ) <EOL> self . assertEqual ( d2 . get_type ( ) , CONSTANT_TYPE_INTEGER ) <EOL> self . assertEqual ( d3 . get_type ( ) , CONSTANT_TYPE_INTEGER ) <EOL> self . assertEqual ( v1 , byte_val ) <EOL> self . assertEqual ( v2 , short_val ) <EOL> self . assertEqual ( v3 , int_val ) <EOL> with self . assertRaises ( HazelcastSerializationError ) : <EOL> service . to_data ( big_int ) <EOL> def test_long_case ( self ) : <EOL> config = SerializationConfig ( ) <EOL> config . default_integer_type = INTEGER_TYPE . LONG <EOL> service = SerializationServiceV1 ( serialization_config = config ) <EOL> d1 = service . to_data ( byte_val ) <EOL> d2 = service . to_data ( short_val ) <EOL> d3 = service . to_data ( int_val ) <EOL> d4 = service . to_data ( long_val ) <EOL> v1 = service . to_object ( d1 ) <EOL> v2 = service . to_object ( d2 ) <EOL> v3 = service . to_object ( d3 ) <EOL> v4 = service . to_object ( d4 ) <EOL> self . assertEqual ( d1 . get_type ( ) , CONSTANT_TYPE_LONG ) <EOL> self . assertEqual ( d2 . get_type ( ) , CONSTANT_TYPE_LONG ) <EOL> self . assertEqual ( d3 . get_type ( ) , CONSTANT_TYPE_LONG ) <EOL> self . assertEqual ( d4 . get_type ( ) , CONSTANT_TYPE_LONG ) <EOL> self . assertEqual ( v1 , byte_val ) <EOL> self . assertEqual ( v2 , short_val ) <EOL> self . assertEqual ( v3 , int_val ) <EOL> self . assertEqual ( v4 , long_val ) <EOL> with self . assertRaises ( HazelcastSerializationError ) : <EOL> service . to_data ( big_int ) </s>
