'Regression test for https://github.com/astropy/astropy/issues/2305
This ensures that an HDU containing unsigned integer data always has
the apppriate BZERO value in its header.'

def test_uint_header_consistency(self):

    for int_size in (16, 32, 64):
        max_uint = ((2 ** int_size) - 1)
        if (int_size == 64):
            max_uint = np.uint64(int_size)
        dtype = 'uint{}'.format(int_size)
        arr = np.empty(100, dtype=dtype)
        arr.fill(max_uint)
        arr -= np.arange(100, dtype=dtype)
        uint_hdu = fits.PrimaryHDU(data=arr)
        assert np.all((uint_hdu.data == arr))
        assert (uint_hdu.data.dtype.name == 'uint{}'.format(int_size))
        assert ('BZERO' in uint_hdu.header)
        assert (uint_hdu.header['BZERO'] == (2 ** (int_size - 1)))
        filename = 'uint{}.fits'.format(int_size)
        uint_hdu.writeto(self.temp(filename))
        with fits.open(self.temp(filename), uint=True) as hdul:
            new_uint_hdu = hdul[0]
            assert np.all((new_uint_hdu.data == arr))
            assert (new_uint_hdu.data.dtype.name == 'uint{}'.format(int_size))
            assert ('BZERO' in new_uint_hdu.header)
            assert (new_uint_hdu.header['BZERO'] == (2 ** (int_size - 1)))
