示例#1
0
    def testReadAndWriteArray(self):
        arena = fract4dc.arena_create(10, 1)
        alloc = fract4dc.arena_alloc(arena, 4, 1, 10)

        for i in range(10):
            val = i
            result = fract4dc.array_set_int(alloc, 1, i, val)
            self.assertEqual(1, result)

        for i in range(10):
            result = fract4dc.array_get_int(alloc, 1, i)
            self.assertEqual((i, 1), result,
                             "bad result %s for %d" % (result, i))

        self.assertEqual((-1, 0), fract4dc.array_get_int(alloc, 1, 10))
        self.assertEqual((-1, 0), fract4dc.array_get_int(alloc, 1, -1))

        self.assertEqual(0, fract4dc.array_set_int(alloc, 1, 10, 99))
        self.assertEqual(0, fract4dc.array_set_int(alloc, 1, -1, 99))
示例#2
0
    def testReadAndWriteArray(self):
        arena = fract4dc.arena_create(10,1)
        alloc = fract4dc.arena_alloc(arena, 4, 1, 10)

        for i in range(10):
            val = i
            result = fract4dc.array_set_int(alloc,1, i,val)
            self.assertEqual(1,result)
            
        for i in range(10):
            result = fract4dc.array_get_int(alloc,1, i)
            self.assertEqual(
                (i,1), result,
                "bad result %s for %d"  % (result, i))

        self.assertEqual((-1,0), fract4dc.array_get_int(alloc,1,10))
        self.assertEqual((-1,0), fract4dc.array_get_int(alloc,1,-1))

        self.assertEqual(0, fract4dc.array_set_int(alloc,1,10,99))
        self.assertEqual(0, fract4dc.array_set_int(alloc,1,-1,99))
示例#3
0
    def testTwoDimensions(self):
        arena = fract4dc.arena_create(10, 2)
        alloc = fract4dc.arena_alloc(arena, 8, 2, 2, 3)

        i = 0
        for y in range(2):
            for x in range(3):
                result = fract4dc.array_set_int(alloc, 2, i, y, x)
                self.assertEqual(1, result, "bad set for %d,%d" % (x, y))
                # print "%d,%d => %d" % (x,y,i)
                i += 1

        i = 0
        for y in range(2):
            for x in range(3):
                val = fract4dc.array_get_int(alloc, 2, y, x)
                # print "%d,%d <= %d" % (x,y,i)
                self.assertEqual(
                    (i, 1), val,
                    "bad result %s instead of %s for %d,%d" % (val,
                                                               (i, 1), x, y))

                i += 1
示例#4
0
    def testTwoDimensions(self):
        arena = fract4dc.arena_create(10,2)
        alloc = fract4dc.arena_alloc(arena, 8, 2, 2, 3)

        i = 0
        for y in range(2):
            for x in range(3):
                result = fract4dc.array_set_int(alloc,2, i, y, x)
                self.assertEqual(
                    1,result,
                    "bad set for %d,%d" % (x,y))
                #print "%d,%d => %d" % (x,y,i)
                i += 1

        i = 0
        for y in range(2):
            for x in range(3):
                val = fract4dc.array_get_int(alloc,2, y, x)
                #print "%d,%d <= %d" % (x,y,i)
                self.assertEqual(
                    (i,1), val,
                    "bad result %s instead of %s for %d,%d" % (val,(i,1),x,y))
                
                i += 1