|
21 | 21 | import org.firebirdsql.gds.JaybirdErrorCodes; |
22 | 22 | import org.hamcrest.Matcher; |
23 | 23 | import org.junit.jupiter.api.Test; |
| 24 | +import org.junit.jupiter.params.ParameterizedTest; |
| 25 | +import org.junit.jupiter.params.provider.ValueSource; |
24 | 26 |
|
25 | 27 | import java.io.ByteArrayOutputStream; |
26 | 28 | import java.io.InputStream; |
|
31 | 33 | import static org.firebirdsql.common.matchers.SQLExceptionMatchers.*; |
32 | 34 | import static org.hamcrest.MatcherAssert.assertThat; |
33 | 35 | import static org.hamcrest.CoreMatchers.*; |
| 36 | +import static org.hamcrest.Matchers.greaterThan; |
34 | 37 | import static org.junit.jupiter.api.Assertions.*; |
35 | 38 |
|
36 | 39 | /** |
@@ -162,6 +165,28 @@ void testGetBytes_long_int() throws Exception { |
162 | 165 | assertArrayEquals(new byte[] { 5, 6, 7, 8, 9 }, data, "Unexpected data"); |
163 | 166 | } |
164 | 167 |
|
| 168 | + @ParameterizedTest |
| 169 | + @ValueSource(longs = { 11, Integer.MAX_VALUE, Integer.MAX_VALUE + 1L, Long.MAX_VALUE }) |
| 170 | + void testGetBytes_long_int_posBeyondEnd(long pos) throws Exception { |
| 171 | + assertThat("Wrong value for pos", pos, greaterThan(10L)); |
| 172 | + FBCachedBlob blob = new FBCachedBlob(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); |
| 173 | + |
| 174 | + byte[] data = blob.getBytes(pos, 5); |
| 175 | + |
| 176 | + assertNotNull(data, "Expected non-null array"); |
| 177 | + assertArrayEquals(new byte[0], data, "Unexpected data"); |
| 178 | + } |
| 179 | + |
| 180 | + @Test |
| 181 | + void testGetBytes_long_int_lengthBeyondEnd() throws Exception { |
| 182 | + FBCachedBlob blob = new FBCachedBlob(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); |
| 183 | + |
| 184 | + byte[] data = blob.getBytes(5, 10); |
| 185 | + |
| 186 | + assertNotNull(data, "Expected non-null array"); |
| 187 | + assertArrayEquals(new byte[] { 5, 6, 7, 8, 9, 10 }, data, "Unexpected data"); |
| 188 | + } |
| 189 | + |
165 | 190 | @Test |
166 | 191 | void testGetBytes() throws Exception { |
167 | 192 | byte[] input = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; |
|
0 commit comments