Skip to content

Commit

Permalink
Add Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
thachlp committed Jul 2, 2024
1 parent c525619 commit 035b5a4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/java/io/lettuce/core/codec/ByteArrayCodecUnitTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.lettuce.core.codec;

import org.junit.jupiter.api.Test;

import java.nio.ByteBuffer;

import static org.assertj.core.api.Assertions.assertThat;

class ByteArrayCodecUnitTests {

@Test
void testDecodeValue_withNonEmptyByteBuffer() {
final ByteArrayCodec byteArrayCodec = ByteArrayCodec.INSTANCE;
final byte[] expectedBytes = { 1, 2, 3, 4, 5 };
final ByteBuffer buffer = ByteBuffer.wrap(expectedBytes);
final byte[] result = byteArrayCodec.decodeValue(buffer);
assertThat(result).isEqualTo(expectedBytes);
}

@Test
void testDecodeValue_withEmptyByteBuffer() {
final ByteArrayCodec byteArrayCodec = ByteArrayCodec.INSTANCE;
final ByteBuffer buffer = ByteBuffer.allocate(0);
final byte[] result = byteArrayCodec.decodeValue(buffer);
assertThat(result).isEmpty();
}

@Test
void testDecodeValue_withNullByteBuffer() {
final ByteArrayCodec byteArrayCodec = ByteArrayCodec.INSTANCE;
final byte[] result = byteArrayCodec.decodeValue(null);
assertThat(result).isEmpty();
}

}

0 comments on commit 035b5a4

Please sign in to comment.