示例#1
0
    def test_change_buffer_manual_fill(self):
        # Fill old buffer with 1s
        self.buf[0] = 1
        position = array.array('i', [0, 0])
        dim_nu, buf_nu = resize_array_buffer(self.dim, self.buf_len)

        # Initialise new buffer to 0
        buf_nu[0] = 0
        # Adds the old buffer, which should fill the whole middle with 1s
        change_buffer(position, self.buf_len, self.dim, self.buf, dim_nu,
                      buf_nu)
        # Check the new buffer has empty rim, but full after.
        self.assertFalse(cy.check_rim(0, dim_nu, buf_nu[0]))
        self.assertTrue(cy.check_rim(1, dim_nu, buf_nu[0]))
示例#2
0
    def test_change_array_manual_fill_cut_and_gap(self):
        # Fill old buffer with 1s
        self.arr[:] = 1
        dim_nu, arr_nu = resize_array(self.dim)

        # Initialise new buffer to 0
        arr_nu[:] = 0
        # This time when changing, offset and cut the old array
        offset = array.array('i', [2, 2])
        cut = array.array('i', [1, 1])
        change_array(self.dim, self.arr, dim_nu, arr_nu, offset, cut)
        # Check the new buffer has a gap all the way around, one step in from the
        # outside.
        self.assertFalse(cy.check_rim(0, dim_nu, arr_nu))
        self.assertFalse(cy.check_rim(1, dim_nu, arr_nu))
        self.assertTrue(cy.check_rim(2, dim_nu, arr_nu))
示例#3
0
    def test_change_buffer_manual_fill_cut_and_gap(self):
        # Fill old buffer with 1s
        self.buf[0] = 1
        position = array.array('i', [0, 0])
        dim_nu, buf_nu = resize_array_buffer(self.dim, self.buf_len)

        # Initialise new buffer to 0
        buf_nu[0] = 0
        # This time, when changing offset and cut the old array
        offset = array.array('i', [2, 2])
        cut = array.array('i', [1, 1])
        change_buffer(position, self.buf_len, self.dim, self.buf, dim_nu,
                      buf_nu, offset, cut)
        # Check the new buffer has a gap all the way around, one step in from the
        # outside.
        self.assertFalse(cy.check_rim(0, dim_nu, buf_nu[0]))
        self.assertFalse(cy.check_rim(1, dim_nu, buf_nu[0]))
        self.assertTrue(cy.check_rim(2, dim_nu, buf_nu[0]))
示例#4
0
 def test_check_rim(self):
     self.assertFalse(cy.check_rim(0, tst_dim(), tst_arr()))
     self.assertTrue(cy.check_rim(1, tst_dim(), tst_arr()))