def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from genpy.message import check_type, SerializationError from genpy import Time, Duration valids = [ ('byte', 1), ('byte', -1), ('string', ''), ('string', 'a string of text'), ('int32[]', []), ('int32[]', [1, 2, 3, 4]), ('time', Time()), ('time', Time.from_sec(1.0)), ('time', Time(10000)), ('time', Time(1000, -100)), ('duration', Duration()), ('duration', Duration()), ('duration', Duration(100)), ('duration', Duration(-100, -100)), ] for t, v in valids: try: check_type('n', t, v) except Exception, e: traceback.print_exc() raise Exception("failure type[%s] value[%s]: %s" % (t, v, str(e)))
def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from genpy.message import check_type, SerializationError from genpy import Time, Duration valids = [ ("byte", 1), ("byte", -1), ("string", ""), ("string", "a string of text"), ("int32[]", []), ("int32[]", [1, 2, 3, 4]), ("time", Time()), ("time", Time.from_sec(1.0)), ("time", Time(10000)), ("time", Time(1000, -100)), ("duration", Duration()), ("duration", Duration()), ("duration", Duration(100)), ("duration", Duration(-100, -100)), ] for t, v in valids: try: check_type("n", t, v) except Exception, e: traceback.print_exc() raise Exception("failure type[%s] value[%s]: %s" % (t, v, str(e)))
def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from genpy.message import check_type, SerializationError from genpy import Time, Duration valids = [ ('byte', 1), ('byte', -1), ('string', ''), ('string', 'a string of text'), ('int32[]', []), ('int32[]', [1, 2, 3, 4]), ('time', Time()), ('time', Time.from_sec(1.0)), ('time', Time(10000)), ('time', Time(1000, -100)), ('duration', Duration()), ('duration', Duration()), ('duration', Duration(100)), ('duration', Duration(-100, -100)), ] for t, v in valids: try: check_type('n', t, v) except Exception as e: traceback.print_exc() raise Exception('failure type[%s] value[%s]: %s' % (t, v, str(e))) invalids = [ ('byte', 129), ('byte', -129), ('byte', 'byte'), ('byte', 1.0), ('string', 1), ('uint32', -1), ('int8', 112312), ('int8', -112312), ('uint8', -1), ('uint8', 112312), ('int32', '1'), ('int32', 1.), ('int32[]', 1), ('int32[]', [1., 2.]), ('int32[]', [1, 2.]), ('duration', 1), ('time', 1), ] for t, v in invalids: try: check_type('n', t, v) self.fail('check_type[%s, %s] should have failed' % (t, v)) except SerializationError: pass
def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from genpy.message import check_type, SerializationError from genpy import Time, Duration valids = [ ('byte', 1), ('byte', -1), ('string', ''), ('string', 'a string of text'), ('int32[]', []), ('int32[]', [1, 2, 3, 4]), ('time', Time()), ('time', Time.from_sec(1.0)), ('time', Time(10000)), ('time', Time(1000, -100)), ('duration', Duration()),('duration', Duration()), ('duration', Duration(100)), ('duration', Duration(-100, -100)), ] for t, v in valids: try: check_type('n', t, v) except Exception as e: traceback.print_exc() raise Exception("failure type[%s] value[%s]: %s"%(t, v, str(e))) invalids = [ ('byte', 129), ('byte', -129), ('byte', 'byte'), ('byte', 1.0), ('string', 1), ('uint32', -1), ('int8', 112312), ('int8', -112312), ('uint8', -1), ('uint8', 112312), ('int32', '1'), ('int32', 1.), ('int32[]', 1), ('int32[]', [1., 2.]), ('int32[]', [1, 2.]), ('duration', 1), ('time', 1), ] for t, v in invalids: try: check_type('n', t, v) self.fail("check_type[%s, %s] should have failed"%(t, v)) except SerializationError: pass