Ejemplo n.º 1
0
 def test_int_littleendian_int32_unsigned_lowedge_load():
     pint.setbyteorder(config.byteorder.littleendian)
     s = '\x00\x00\x00\x00'
     a = pint.int32_t(source=provider.string(s)).l
     b, = struct.unpack('l',s)
     if a.int() == b and a.serialize() == s:
         raise Success
     print b,a, repr(a.serialize())
Ejemplo n.º 2
0
            except Success, e:
                print '%s: %r' % (name, e)
                return True
            except Failure, e:
                print '%s: %r' % (name, e)
            except Exception, e:
                print '%s: %r : %r' % (name, Failure(), e)
            return False

        TestCaseList.append(harness)
        return fn


if __name__ == '__main__':
    import struct, pint, config
    pint.setbyteorder(config.byteorder.bigendian)

    ## data
    single_precision = [
        (0x3f800000, 1.0),
        (0xc0000000, -2.0),
        (0x7f7fffff, 3.4028234663852886e+38),
        #        (0x00000000, 0.0),
        #        (0x80000000, -0.0),
        #        (0x7f800000, 0),
        #        (0xff800000, -0),
        (0x3eaaaaab, 1.0 / 3),
        (0x41c80000, 25.0),
    ]

    double_precision = [
Ejemplo n.º 3
0
                res = fn(**kwds)
                raise Failure
            except Success,e:
                print '%s: %r'% (name,e)
                return True
            except Failure,e:
                print '%s: %r'% (name,e)
            except Exception,e:
                print '%s: %r : %r'% (name,Failure(), e)
            return False
        TestCaseList.append(harness)
        return fn

if __name__ == '__main__':
    import struct,pint,config
    pint.setbyteorder(config.byteorder.bigendian)

    ## data
    single_precision = [
        (0x3f800000, 1.0),
        (0xc0000000, -2.0),
        (0x7f7fffff, 3.4028234663852886e+38),
        #        (0x00000000, 0.0),
        #        (0x80000000, -0.0),
        #        (0x7f800000, 0),
        #        (0xff800000, -0),
        (0x3eaaaaab, 1.0/3),
        (0x41c80000, 25.0),
    ]

    double_precision = [
Ejemplo n.º 4
0
 def test_int_revert_littleendian_uint32_load():
     pint.setbyteorder(config.byteorder.littleendian)
     a = pint.uint32_t(source=provider.string(string2)).l
     if a.int() == 0x0abcdef0 and a.serialize() == string2:
         raise Success
     print a, repr(a.serialize())