示例#1
0
    def test_datatypes(self):
        from Sybase import numeric
        from decimal import Decimal

        num = numeric(Decimal("100.5"))
        self.assertEquals("%r" % num, "100.5")
        num = numeric(Decimal("0.000001"))
        self.assertEquals("%r" % num, "0.000001")
        num = numeric(Decimal("-1e-23"))
        self.assertEquals("%r" % num, "-0.00000000000000000000001")
        num = numeric("-1111111111111111111111111111111111111111111111111111111111111111111111111111.1")
        self.assertEquals("%r" % num, "-1111111111111111111111111111111111111111111111111111111111111111111111111111.1")
        num = numeric(50000000000L)
        self.assertEquals("%r" % num, "50000000000")        
示例#2
0
    def test_datatypes(self):
        from Sybase import numeric
        from decimal import Decimal

        num = numeric(Decimal("100.5"))
        self.assertEquals("%r" % num, "100.5")
        num = numeric(Decimal("0.000001"))
        self.assertEquals("%r" % num, "0.000001")
        num = numeric(Decimal("-1e-23"))
        self.assertEquals("%r" % num, "-0.00000000000000000000001")
        num = numeric(
            "-1111111111111111111111111111111111111111111111111111111111111111111111111111.1"
        )
        self.assertEquals(
            "%r" % num,
            "-1111111111111111111111111111111111111111111111111111111111111111111111111111.1"
        )
        num = numeric(50000000000L)
        self.assertEquals("%r" % num, "50000000000")
    def test_sybase_num_parsing(self):
        import Sybase
        from Sybase import numeric
        Sybase._ctx.debug = 1
        Sybase.set_debug(open('sybase_debug.log', 'w'))

        num = numeric("1")
        self.assertEquals((num.precision, num.scale), (1,0))
        num = numeric("-1")
        self.assertEquals((num.precision, num.scale), (1,0))
        num = numeric("1.0")
        self.assertEquals((num.precision, num.scale), (2,1))
        num = numeric("1.003")
        self.assertEquals((num.precision, num.scale), (4,3))
        num = numeric("3e5")
        self.assertEquals((num.precision, num.scale), (6,0))
        num = numeric("1.01e12")
        self.assertEquals((num.precision, num.scale), (13,0))
        num = numeric("1.456e-5")
        self.assertEquals((num.precision, num.scale), (8,8))
        num = numeric("-1.456e-5")
        self.assertEquals((num.precision, num.scale), (8,8))
示例#4
0
    def test_sybase_num_parsing(self):
        import Sybase
        from Sybase import numeric
        Sybase._ctx.debug = 1
        Sybase.set_debug(open('sybase_debug.log', 'w'))

        num = numeric("1")
        self.assertEquals((num.precision, num.scale), (1, 0))
        num = numeric("-1")
        self.assertEquals((num.precision, num.scale), (1, 0))
        num = numeric("1.0")
        self.assertEquals((num.precision, num.scale), (2, 1))
        num = numeric("1.003")
        self.assertEquals((num.precision, num.scale), (4, 3))
        num = numeric("3e5")
        self.assertEquals((num.precision, num.scale), (6, 0))
        num = numeric("1.01e12")
        self.assertEquals((num.precision, num.scale), (13, 0))
        num = numeric("1.456e-5")
        self.assertEquals((num.precision, num.scale), (8, 8))
        num = numeric("-1.456e-5")
        self.assertEquals((num.precision, num.scale), (8, 8))