Skip to content

Commit

Permalink
Fix parameter check in RecordBuilder#setSystemChar()
Browse files Browse the repository at this point in the history
The parameter check did not fail on indix values greater than 2 which
exceeds the space for system chars in Marc 21 records.

Fixes #283

(cherry picked from commit f96ef28)
  • Loading branch information
cboehme committed Dec 19, 2018
1 parent 7313127 commit b26fd24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void setSystemChars(final char[] systemChars) {
}

public void setSystemChar(final int index, final char value) {
Require.that(0 <= index && index < IMPL_CODES_LENGTH);
Require.that(0 <= index && index < SYSTEM_CHARS_LENGTH);
Require.that(value < Iso646Constants.MAX_CHAR_CODE);
label.setSystemChar(index, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public void shouldThrowExceptionIfSystemCharsIsNull() {
builder.setSystemChars(null); // Exception expected
}

@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionIfSystemCharIndexGreaterThan2() {
builder.setSystemChar(3, '1');
}

@Test
public void shouldWriteReserverdCharToRecordLabel() {
builder.setReservedChar('R');
Expand Down

0 comments on commit b26fd24

Please sign in to comment.