static boolean checkConverterState(PNGConverterState state)
    {
        if (state == null)
        {
            return false;
        }
        if (state.IHDR == null || !checkChunkSane(state.IHDR))
        {
            LOG.error("Invalid IHDR chunk.");
            return false;
        }
        if (!checkChunkSane(state.PLTE))
        {
            LOG.error("Invalid PLTE chunk.");
            return false;
        }
        if (!checkChunkSane(state.iCCP))
        {
            LOG.error("Invalid iCCP chunk.");
            return false;
        }
        if (!checkChunkSane(state.tRNS))
        {
            LOG.error("Invalid tRNS chunk.");
            return false;
        }
        if (!checkChunkSane(state.sRGB))
        {
            LOG.error("Invalid sRGB chunk.");
            return false;
        }
        if (!checkChunkSane(state.cHRM))
        {
            LOG.error("Invalid cHRM chunk.");
            return false;
        }
        if (!checkChunkSane(state.gAMA))
        {
            LOG.error("Invalid gAMA chunk.");
            return false;
        }

        // Check the IDATs
        if (state.IDATs.isEmpty())
        {
            LOG.error("No IDAT chunks.");
            return false;
        }
        for (Chunk idat : state.IDATs)
        {
            if (!checkChunkSane(idat))
            {
                LOG.error("Invalid IDAT chunk.");
                return false;
            }
        }
        return true;
    }
@Test
    void testCheckConverterState()
    {
        assertFalse(PNGConverter.checkConverterState(null));
        PNGConverter.PNGConverterState state = new PNGConverter.PNGConverterState();
        assertFalse(PNGConverter.checkConverterState(state));

        PNGConverter.Chunk invalidChunk = new PNGConverter.Chunk();
        invalidChunk.bytes = new byte[0];
        assertFalse(PNGConverter.checkChunkSane(invalidChunk));

        // Valid Dummy Chunk
        PNGConverter.Chunk validChunk = new PNGConverter.Chunk();
        validChunk.bytes = new byte[16];
        validChunk.start = 4;
        validChunk.length = 8;
        validChunk.crc = 2077607535;
        assertTrue(PNGConverter.checkChunkSane(validChunk));

        state.IHDR = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.IDATs = Collections.singletonList(validChunk);
        assertFalse(PNGConverter.checkConverterState(state));
        state.IHDR = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));
        state.IDATs = new ArrayList<>();
        assertFalse(PNGConverter.checkConverterState(state));
        state.IDATs = Collections.singletonList(validChunk);
        assertTrue(PNGConverter.checkConverterState(state));

        state.PLTE = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.PLTE = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.cHRM = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.cHRM = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.tRNS = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.tRNS = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.iCCP = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.iCCP = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.sRGB = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.sRGB = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.gAMA = invalidChunk;
        assertFalse(PNGConverter.checkConverterState(state));
        state.gAMA = validChunk;
        assertTrue(PNGConverter.checkConverterState(state));

        state.IDATs = Arrays.asList(validChunk, invalidChunk);
        assertFalse(PNGConverter.checkConverterState(state));
    }