MCPcopy Index your code
hub / github.com/assertj/assertj / ByteArrays

Class ByteArrays

src/main/java/org/assertj/core/internal/ByteArrays.java:30–301  ·  view source on GitHub ↗

Reusable assertions for arrays of bytes. @author Alex Ruiz @author Mikhail Mazursky @author Nicolas François

Source from the content-addressed store, hash-verified

28 * @author Nicolas François
29 */
30public class ByteArrays {
31
32 private static final ByteArrays INSTANCE = new ByteArrays();
33
34 /**
35 * Returns the singleton instance of this class.
36 * @return the singleton instance of this class.
37 */
38 public static ByteArrays instance() {
39 return INSTANCE;
40 }
41
42 private Arrays arrays = Arrays.instance();
43
44 @VisibleForTesting
45 Failures failures = Failures.instance();
46
47 @VisibleForTesting
48 ByteArrays() {
49 this(StandardComparisonStrategy.instance());
50 }
51
52 public ByteArrays(ComparisonStrategy comparisonStrategy) {
53 this.arrays = new Arrays(comparisonStrategy);
54 }
55
56 @VisibleForTesting
57 public Comparator<?> getComparator() {
58 return arrays.getComparator();
59 }
60
61 /**
62 * Asserts that the given array is {@code null} or empty.
63 * @param info contains information about the assertion.
64 * @param actual the given array.
65 * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements.
66 */
67 public void assertNullOrEmpty(AssertionInfo info, byte[] actual) {
68 arrays.assertNullOrEmpty(info, failures, actual);
69 }
70
71 /**
72 * Asserts that the given array is empty.
73 * @param info contains information about the assertion.
74 * @param actual the given array.
75 * @throws AssertionError if the given array is {@code null}.
76 * @throws AssertionError if the given array is not empty.
77 */
78 public void assertEmpty(AssertionInfo info, byte[] actual) {
79 arrays.assertEmpty(info, failures, actual);
80 }
81
82 /**
83 * Asserts that the given array is not empty.
84 * @param info contains information about the assertion.
85 * @param actual the given array.
86 * @throws AssertionError if the given array is {@code null}.
87 * @throws AssertionError if the given array is empty.

Callers

nothing calls this directly

Calls 2

instanceMethod · 0.95
instanceMethod · 0.95

Tested by

no test coverage detected