mirror of https://github.com/jwtk/jjwt.git
113: moar tests
This commit is contained in:
parent
716c6fd500
commit
3bcd7632cd
|
@ -3,7 +3,11 @@ package io.jsonwebtoken.lang;
|
|||
/**
|
||||
* @since 0.6
|
||||
*/
|
||||
public abstract class Arrays {
|
||||
public final class Arrays {
|
||||
|
||||
private static final Arrays INSTANCE = new Arrays();
|
||||
|
||||
private Arrays(){}
|
||||
|
||||
public static int length(byte[] bytes) {
|
||||
return bytes != null ? bytes.length : 0;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package io.jsonwebtoken.lang
|
||||
|
||||
import groovy.json.internal.Charsets
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.*
|
||||
|
||||
class ArraysTest {
|
||||
|
||||
@Test
|
||||
void testByteArrayLengthWithNull() {
|
||||
assertEquals 0, Arrays.length(null)
|
||||
}
|
||||
|
||||
@Test
|
||||
void testByteArrayLengthWithEmpty() {
|
||||
assertEquals 0, Arrays.length(new byte[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
void testByteArrayLengthWithElements() {
|
||||
byte[] bytes = "hello".getBytes(Charsets.UTF_8)
|
||||
assertEquals 5, Arrays.length(bytes)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue