def test_array_serializer_generator_numpy(): is_numpy = True from genpy.generator import array_serializer_generator d = os.path.join(get_test_dir(), 'array') # generator tests are mainly tripwires/coverage tests #array_serializer_generator(msg_context, package, type_, name, serialize, is_numpy): msg_context = MsgContext.create_default() # permutations: var length, unint8 serialize = True result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_ser_np.txt', result) serialize = False result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_deser_np.txt', result)
def test_array_serializer_generator_numpy(): is_numpy = True from genpy.generator import array_serializer_generator d = os.path.join(get_test_dir(), 'array') # generator tests are mainly tripwires/coverage tests # array_serializer_generator(msg_context, package, type_, name, serialize, is_numpy): msg_context = MsgContext.create_default() # permutations: var length, unint8 serialize = True result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_ser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_ser_np.txt', result) serialize = False result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_deser_np.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_deser_np.txt', result)
def test_array_serializer_generator(): from genmsg.msg_loader import load_msg_by_type from genpy.generator import array_serializer_generator, MsgGenerationException, reset_var d = os.path.join(get_test_dir(), 'array') # generator tests are mainly tripwires/coverage tests #array_serializer_generator(msg_context, package, type_, name, serialize, is_numpy): msg_context = MsgContext.create_default() # load in some objects search_path = {'foo': [d]} load_msg_by_type(msg_context, 'foo/Object', search_path) load_msg_by_type(msg_context, 'foo/ObjectArray', search_path) # permutations: var length, unint8 is_numpy = False serialize = True result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_ser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_ser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[]', 'data', serialize, is_numpy) compare_file(d, 'bool_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[3]', 'data', serialize, is_numpy) compare_file(d, 'bool_fixed_ser.txt', result) # for 'complex' types have to reset the variable generator reset_var() result = array_serializer_generator(msg_context, '', 'string[]', 'data', serialize, is_numpy) compare_file(d, 'string_varlen_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, '', 'string[2]', 'data', serialize, is_numpy) compare_file(d, 'string_fixed_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[]', 'data', serialize, is_numpy) compare_file(d, 'object_varlen_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[3]', 'data', serialize, is_numpy) compare_file(d, 'object_fixed_ser.txt', result) serialize = False result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_deser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_deser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[]', 'data', serialize, is_numpy) compare_file(d, 'bool_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[3]', 'data', serialize, is_numpy) compare_file(d, 'bool_fixed_deser.txt', result) # for 'complex' types have to reset the variable generator reset_var() result = array_serializer_generator(msg_context, '', 'string[]', 'data', serialize, is_numpy) compare_file(d, 'string_varlen_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, '', 'string[2]', 'data', serialize, is_numpy) compare_file(d, 'string_fixed_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[]', 'data', serialize, is_numpy) compare_file(d, 'object_varlen_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[3]', 'data', serialize, is_numpy) compare_file(d, 'object_fixed_deser.txt', result) # test w/ bad args try: result = array_serializer_generator(msg_context, '', 'uint8', 'data', True, False) exhaust(result) assert False, "should have raised" except MsgGenerationException: pass
def test_array_serializer_generator(): from genmsg.msg_loader import load_msg_by_type from genpy.generator import array_serializer_generator, MsgGenerationException, reset_var d = os.path.join(get_test_dir(), 'array') # generator tests are mainly tripwires/coverage tests # array_serializer_generator(msg_context, package, type_, name, serialize, is_numpy): msg_context = MsgContext.create_default() # load in some objects search_path = {'foo': [d]} load_msg_by_type(msg_context, 'foo/Object', search_path) load_msg_by_type(msg_context, 'foo/ObjectArray', search_path) # permutations: var length, unint8 is_numpy = False serialize = True result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_ser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_ser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[]', 'data', serialize, is_numpy) compare_file(d, 'bool_varlen_ser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[3]', 'data', serialize, is_numpy) compare_file(d, 'bool_fixed_ser.txt', result) # for 'complex' types have to reset the variable generator reset_var() result = array_serializer_generator(msg_context, '', 'string[]', 'data', serialize, is_numpy) compare_file(d, 'string_varlen_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, '', 'string[2]', 'data', serialize, is_numpy) compare_file(d, 'string_fixed_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[]', 'data', serialize, is_numpy) compare_file(d, 'object_varlen_ser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[3]', 'data', serialize, is_numpy) compare_file(d, 'object_fixed_ser.txt', result) serialize = False result = array_serializer_generator(msg_context, '', 'uint8[]', 'data', serialize, is_numpy) compare_file(d, 'uint8_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[]', 'data', serialize, is_numpy) compare_file(d, 'int16_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'uint8[8]', 'data', serialize, is_numpy) compare_file(d, 'uint8_fixed_deser.txt', result) result = array_serializer_generator(msg_context, '', 'int16[10]', 'data', serialize, is_numpy) compare_file(d, 'int16_fixed_deser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[]', 'data', serialize, is_numpy) compare_file(d, 'bool_varlen_deser.txt', result) result = array_serializer_generator(msg_context, '', 'bool[3]', 'data', serialize, is_numpy) compare_file(d, 'bool_fixed_deser.txt', result) # for 'complex' types have to reset the variable generator reset_var() result = array_serializer_generator(msg_context, '', 'string[]', 'data', serialize, is_numpy) compare_file(d, 'string_varlen_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, '', 'string[2]', 'data', serialize, is_numpy) compare_file(d, 'string_fixed_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[]', 'data', serialize, is_numpy) compare_file(d, 'object_varlen_deser.txt', result) reset_var() result = array_serializer_generator(msg_context, 'foo', 'foo/Object[3]', 'data', serialize, is_numpy) compare_file(d, 'object_fixed_deser.txt', result) # test w/ bad args try: result = array_serializer_generator(msg_context, '', 'uint8', 'data', True, False) exhaust(result) assert False, 'should have raised' except MsgGenerationException: pass