Skip to content

Commit

Permalink
Add test for missing coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed May 17, 2024
1 parent 3fe0bba commit ed3a358
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,30 @@ public void reverse_null() {
ModbusByteUtils.reverse(null);
}

@Test
public void encode16() {
// GIVEN
final byte[] data = new byte[2];

// WHEN
ModbusByteUtils.encode16(data, 0, 0xabcd);

// THEN
assertThat("Data encoded", Arrays.equals(data, new byte[] { (byte) 0xab, (byte) 0xcd }),
is(equalTo(true)));
}

@Test
public void encode16_offset() {
// GIVEN
final byte[] data = new byte[] { 1, 2, 3, 4 };

// WHEN
ModbusByteUtils.encode16(data, 2, 0xabcd);

// THEN
assertThat("Data encoded", Arrays.equals(data, new byte[] { 1, 2, (byte) 0xab, (byte) 0xcd }),
is(equalTo(true)));
}

}

0 comments on commit ed3a358

Please sign in to comment.