-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed as not planned
Description
I'd like to propose the addition of implicit conversion from integral numbers (byte
, short
, int
, long
) to byte array. The concrete use case is code dealing with bitwise operations, mostly related to cryptography.
My wish is to write something like this:
@ParameterizedTest
@ValueSource(ints = {Integer.MIN_VALUE, 0, 0xFF, 0xFFFF, 0xFFFFFF, Integer.MAX_VALUE})
void test(byte[] byteArray) {
assertThat(byteArray).hasSize(4);
}
where I can leverage binary and hexadecimal literals which are automatically converted to a byte array using a ByteBuffer
with Big Endian order.
I put together a small poc with a custom argument converter. If the proposal is accepted, I'm happy to raise a PR about it.
Deliverables
- A new implicit conversion from
byte
/short
/int
/long
tobyte[]