'Tests a few corner-cases for the realign_dtype hack.
These are unlikely to come in practice given how this is currently
used in astropy.io.fits, but nonetheless tests for bugs that were
present in earlier versions of the function.'

def test_realign_dtype(self):

    dt = np.dtype([('a', np.int32), ('b', np.int16)])
    dt2 = realign_dtype(dt, [0, 0])
    assert (dt2.itemsize == 4)
    dt2 = realign_dtype(dt, [0, 1])
    assert (dt2.itemsize == 4)
    dt2 = realign_dtype(dt, [1, 0])
    assert (dt2.itemsize == 5)
    dt = np.dtype([('a', np.float64), ('b', np.int8), ('c', np.int8)])
    dt2 = realign_dtype(dt, [0, 0, 0])
    assert (dt2.itemsize == 8)
    dt2 = realign_dtype(dt, [0, 0, 1])
    assert (dt2.itemsize == 8)
    dt2 = realign_dtype(dt, [0, 0, 27])
    assert (dt2.itemsize == 28)
