protected final int nextStringEndPos(byte[] bytes, int startPos, int limit, byte[] delimiter) {
        int endPos = startPos;

        final int delimLimit = limit - delimiter.length + 1;

        while (endPos < limit) {
            if (endPos < delimLimit && delimiterNext(bytes, endPos, delimiter)) {
                break;
            }
            endPos++;
        }

        if (endPos == startPos) {
            setErrorState(ParseErrorState.EMPTY_COLUMN);
            return -1;
        }
        return endPos;
    }
@Test
    void testNextStringEndPos() {

        FieldParser parser = new TestFieldParser<String>();
        // single-char delimiter
        byte[] singleCharDelim = "|".getBytes(ConfigConstants.DEFAULT_CHARSET);

        byte[] bytes1 = "a|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        assertThat(parser.nextStringEndPos(bytes1, 0, bytes1.length, singleCharDelim)).isOne();
        assertThat(parser.nextStringEndPos(bytes1, 1, bytes1.length, singleCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes1, 1, 1, singleCharDelim)).isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes1, 2, bytes1.length, singleCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        byte[] bytes2 = "a||".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes2, 1, bytes2.length, singleCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        byte[] bytes3 = "a|c".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes3, 1, bytes3.length, singleCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes3, 2, bytes3.length, singleCharDelim)).isEqualTo(3);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.NONE);

        byte[] bytes4 = "a|c|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(bytes4, 2, bytes4.length, singleCharDelim)).isEqualTo(3);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.NONE);

        // multi-char delimiter
        byte[] multiCharDelim = "|#|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        byte[] mBytes1 = "a|#|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes1, 0, mBytes1.length, multiCharDelim)).isOne();
        assertThat(parser.nextStringEndPos(mBytes1, 1, mBytes1.length, multiCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes1, 1, 1, multiCharDelim)).isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        byte[] mBytes2 = "a|#||#|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes2, 1, mBytes2.length, multiCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        byte[] mBytes3 = "a|#|b".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes3, 1, mBytes3.length, multiCharDelim))
                .isEqualTo(-1);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.EMPTY_COLUMN);

        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes3, 2, mBytes3.length, multiCharDelim))
                .isEqualTo(5);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.NONE);

        byte[] mBytes4 = "a|#|b|#|".getBytes(ConfigConstants.DEFAULT_CHARSET);
        parser.resetParserState();
        assertThat(parser.nextStringEndPos(mBytes4, 2, mBytes4.length, multiCharDelim))
                .isEqualTo(5);
        assertThat(parser.getErrorState()).isEqualTo(ParseErrorState.NONE);
    }