def _c_wrapper(self, value): try: return c_uamqp.long_value(int(value)) except TypeError: raise ValueError("Value must be an integer") except OverflowError: raise ValueError("Value {} is too large for a Long value.".format(value))
def _convert_py_number(value): """Convert a Python integer value into equivalent C object. Will attempt to use the smallest possible conversion, starting with int, then long then double. """ try: return c_uamqp.int_value(value) except OverflowError: pass try: return c_uamqp.long_value(value) except OverflowError: pass return c_uamqp.double_value(value)
def test_long_value(): value = c_uamqp.long_value(5) assert value.value == 5 assert value.type == c_uamqp.AMQPType.LongValue assert str(value) == "5"