1
1
package org .hamcrest .collection ;
2
2
3
+ import org .hamcrest .FeatureMatcher ;
3
4
import org .hamcrest .Matcher ;
4
5
5
6
import java .util .Collection ;
6
7
7
8
import static org .hamcrest .core .DescribedAs .describedAs ;
9
+ import static org .hamcrest .core .IsEqual .equalTo ;
8
10
9
11
public class MatchArrays {
10
12
/**
@@ -166,7 +168,9 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) {
166
168
* @param sizeMatcher a matcher for the length of an examined array
167
169
*/
168
170
public static <E > Matcher <E []> arrayWithSize (Matcher <? super Integer > sizeMatcher ) {
169
- return IsArrayWithSize .arrayWithSize (sizeMatcher );
171
+ return new FeatureMatcher <E [], Integer > (sizeMatcher , "an array with size" ,"array size" ) {
172
+ @ Override protected Integer featureValueOf (E [] actual ) { return actual .length ; }
173
+ };
170
174
}
171
175
172
176
/**
@@ -178,7 +182,7 @@ public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatche
178
182
* @param size the length that an examined array must have for a positive match
179
183
*/
180
184
public static <E > Matcher <E []> arrayWithSize (int size ) {
181
- return IsArrayWithSize . arrayWithSize (size );
185
+ return arrayWithSize (equalTo ( size ) );
182
186
}
183
187
184
188
/**
@@ -188,7 +192,7 @@ public static <E> Matcher<E[]> arrayWithSize(int size) {
188
192
* <pre>assertThat(new String[0], emptyArray())</pre>
189
193
*/
190
194
public static <E > Matcher <E []> emptyArray () {
191
- return describedAs ("an empty array" , IsArrayWithSize .<E >arrayWithSize (0 ));
195
+ return describedAs ("an empty array" , MatchArrays .<E >arrayWithSize (0 ));
192
196
}
193
197
194
198
}
0 commit comments