示例#1
0
    def testUInt64Conversion(self):
        """Test uint64 conversion."""
        self.assertTrue(System.UInt64.MaxValue == long(18446744073709551615))
        self.assertTrue(System.UInt64.MinValue == 0)

        object = ConversionTest()
        self.assertTrue(object.UInt64Field == 0)

        object.UInt64Field = long(18446744073709551615)
        self.assertTrue(object.UInt64Field == long(18446744073709551615))

        object.UInt64Field = -0
        self.assertTrue(object.UInt64Field == 0)

        object.UInt64Field = System.UInt64(long(18446744073709551615))
        self.assertTrue(object.UInt64Field == long(18446744073709551615))

        object.UInt64Field = System.UInt64(0)
        self.assertTrue(object.UInt64Field == 0)

        def test():
            ConversionTest().UInt64Field = "spam"

        self.assertRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = None

        self.assertRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = long(18446744073709551616)

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().UInt64Field = -1

        self.assertRaises(OverflowError, test)

        def test():
            value = System.UInt64(long(18446744073709551616))

        self.assertRaises(OverflowError, test)

        def test():
            value = System.UInt64(-1)

        self.assertRaises(OverflowError, test)
    def testUInt64Conversion(self):
        """Test uint64 conversion."""
        self.failUnless(System.UInt64.MaxValue == 18446744073709551615L)
        self.failUnless(System.UInt64.MinValue == 0)

        object = ConversionTest()
        self.failUnless(object.UInt64Field == 0)

        object.UInt64Field = 18446744073709551615L
        self.failUnless(object.UInt64Field == 18446744073709551615L)

        object.UInt64Field = -0
        self.failUnless(object.UInt64Field == 0)

        object.UInt64Field = System.UInt64(18446744073709551615L)
        self.failUnless(object.UInt64Field == 18446744073709551615L)

        object.UInt64Field = System.UInt64(0)
        self.failUnless(object.UInt64Field == 0)

        def test():
            ConversionTest().UInt64Field = "spam"
            
        self.failUnlessRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = None
            
        self.failUnlessRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = 18446744073709551616L
            
        self.failUnlessRaises(OverflowError, test)

        def test():
            ConversionTest().UInt64Field = -1
            
        self.failUnlessRaises(OverflowError, test)

        def test():
            value = System.UInt64(18446744073709551616L)
            
        self.failUnlessRaises(OverflowError, test)

        def test():
            value = System.UInt64(-1)
            
        self.failUnlessRaises(OverflowError, test)
示例#3
0
    def testUInt64Conversion(self):
        """Test uint64 conversion."""
        self.assertTrue(System.UInt64.MaxValue == long(18446744073709551615))
        self.assertTrue(System.UInt64.MinValue == 0)

        object = ConversionTest()
        self.assertTrue(object.UInt64Field == 0)

        object.UInt64Field = long(18446744073709551615)
        self.assertTrue(object.UInt64Field == long(18446744073709551615))

        object.UInt64Field = -0
        self.assertTrue(object.UInt64Field == 0)

        object.UInt64Field = System.UInt64(long(18446744073709551615))
        self.assertTrue(object.UInt64Field == long(18446744073709551615))

        object.UInt64Field = System.UInt64(0)
        self.assertTrue(object.UInt64Field == 0)

        def test():
            ConversionTest().UInt64Field = "spam"

        self.assertRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = None

        self.assertRaises(TypeError, test)

        def test():
            ConversionTest().UInt64Field = long(18446744073709551616)

        self.assertRaises(OverflowError, test)

        def test():
            ConversionTest().UInt64Field = -1

        self.assertRaises(OverflowError, test)

        def test():
            value = System.UInt64(long(18446744073709551616))

        self.assertRaises(OverflowError, test)

        def test():
            value = System.UInt64(-1)

        self.assertRaises(OverflowError, test)
示例#4
0
def test_uint64_conversion():
    """Test uint64 conversion."""
    assert System.UInt64.MaxValue == 18446744073709551615
    assert System.UInt64.MinValue == 0

    ob = ConversionTest()
    assert ob.UInt64Field == 0

    ob.UInt64Field = 18446744073709551615
    assert ob.UInt64Field == 18446744073709551615

    ob.UInt64Field = -0
    assert ob.UInt64Field == 0

    ob.UInt64Field = System.UInt64(18446744073709551615)
    assert ob.UInt64Field == 18446744073709551615

    ob.UInt64Field = System.UInt64(0)
    assert ob.UInt64Field == 0

    # Implicitly converts float 0.5 -> int 0
    #with pytest.raises(TypeError):
    #ConversionTest().UInt64Field = 0.5

    with pytest.raises(ValueError):
        ConversionTest().UInt64Field = "spam"

    with pytest.raises(TypeError):
        ConversionTest().UInt64Field = None

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = 18446744073709551616

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = -1

    with pytest.raises(OverflowError):
        _ = System.UInt64((18446744073709551616))

    with pytest.raises(OverflowError):
        _ = System.UInt64(-1)
示例#5
0
    def test_uint64_conversion(self):
        """Test uint64 conversion."""
        self.assertTrue(System.UInt64.MaxValue == long(18446744073709551615))
        self.assertTrue(System.UInt64.MinValue == 0)

        ob = ConversionTest()
        self.assertTrue(ob.UInt64Field == 0)

        ob.UInt64Field = long(18446744073709551615)
        self.assertTrue(ob.UInt64Field == long(18446744073709551615))

        ob.UInt64Field = -0
        self.assertTrue(ob.UInt64Field == 0)

        ob.UInt64Field = System.UInt64(long(18446744073709551615))
        self.assertTrue(ob.UInt64Field == long(18446744073709551615))

        ob.UInt64Field = System.UInt64(0)
        self.assertTrue(ob.UInt64Field == 0)

        with self.assertRaises(TypeError):
            ConversionTest().UInt64Field = "spam"

        with self.assertRaises(TypeError):
            ConversionTest().UInt64Field = None

        with self.assertRaises(OverflowError):
            ConversionTest().UInt64Field = long(18446744073709551616)

        with self.assertRaises(OverflowError):
            ConversionTest().UInt64Field = -1

        with self.assertRaises(OverflowError):
            _ = System.UInt64(long(18446744073709551616))

        with self.assertRaises(OverflowError):
            _ = System.UInt64(-1)
示例#6
0
def test_uint64_conversion():
    """Test uint64 conversion."""
    assert System.UInt64.MaxValue == long(18446744073709551615)
    assert System.UInt64.MinValue == 0

    ob = ConversionTest()
    assert ob.UInt64Field == 0

    ob.UInt64Field = long(18446744073709551615)
    assert ob.UInt64Field == long(18446744073709551615)

    ob.UInt64Field = -0
    assert ob.UInt64Field == 0

    ob.UInt64Field = System.UInt64(long(18446744073709551615))
    assert ob.UInt64Field == long(18446744073709551615)

    ob.UInt64Field = System.UInt64(0)
    assert ob.UInt64Field == 0

    with pytest.raises(TypeError):
        ConversionTest().UInt64Field = "spam"

    with pytest.raises(TypeError):
        ConversionTest().UInt64Field = None

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = long(18446744073709551616)

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = -1

    with pytest.raises(OverflowError):
        _ = System.UInt64(long(18446744073709551616))

    with pytest.raises(OverflowError):
        _ = System.UInt64(-1)
示例#7
0
def test_uint64_conversion():
    """Test uint64 conversion."""
    assert System.UInt64.MaxValue == long(18446744073709551615)
    assert System.UInt64.MinValue == 0

    ob = ConversionTest()
    assert ob.UInt64Field == 0

    ob.UInt64Field = long(18446744073709551615)
    assert ob.UInt64Field == long(18446744073709551615)

    ob.UInt64Field = -0
    assert ob.UInt64Field == 0

    ob.UInt64Field = System.UInt64(long(18446744073709551615))
    assert ob.UInt64Field == long(18446744073709551615)

    ob.UInt64Field = System.UInt64(0)
    assert ob.UInt64Field == 0

    with pytest.raises(TypeError):
        ConversionTest().UInt64Field = "spam"

    with pytest.raises(TypeError):
        ConversionTest().UInt64Field = None

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = long(18446744073709551616)

    with pytest.raises(OverflowError):
        ConversionTest().UInt64Field = -1

    with pytest.raises(OverflowError):
        _ = System.UInt64(long(18446744073709551616))

    with pytest.raises(OverflowError):
        _ = System.UInt64(-1)