| 1 | |
package net.sf.cotta.test.assertion; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
public class ByteListAssert extends ListAssert<Byte> { |
| 7 | |
|
| 8 | |
public ByteListAssert(byte[] value) { |
| 9 | 1 | this(asList(value)); |
| 10 | 1 | } |
| 11 | |
|
| 12 | |
private static List<Byte> asList(byte[] value) { |
| 13 | 1 | if (value == null) { |
| 14 | 1 | return null; |
| 15 | |
} |
| 16 | 0 | List<Byte> bytes = new ArrayList<Byte>(value.length); |
| 17 | 0 | for (byte item : value) { |
| 18 | 0 | bytes.add(item); |
| 19 | |
} |
| 20 | 0 | return bytes; |
| 21 | |
} |
| 22 | |
|
| 23 | |
public ByteListAssert(List<Byte> value) { |
| 24 | 1 | super(value); |
| 25 | 1 | } |
| 26 | |
|
| 27 | |
public ByteListAssert eq(int... expected) { |
| 28 | 0 | List<Byte> bytes = new ArrayList<Byte>(expected.length); |
| 29 | 0 | for (int value : expected) { |
| 30 | 0 | bytes.add((byte) value); |
| 31 | |
} |
| 32 | 0 | eq(bytes); |
| 33 | 0 | return this; |
| 34 | |
} |
| 35 | |
|
| 36 | |
public ByteListAssert eq(byte... expected) { |
| 37 | 0 | List<Byte> list = new ArrayList<Byte>(expected.length); |
| 38 | 0 | for (byte value : expected) { |
| 39 | 0 | list.add(value); |
| 40 | |
} |
| 41 | 0 | eq(list); |
| 42 | 0 | return this; |
| 43 | |
} |
| 44 | |
|
| 45 | |
} |