Clover coverage report - EasyMock 1.2_Java1.5
Coverage timestamp: So Aug 7 2005 17:48:15 CEST
file stats: LOC: 65   Methods: 4
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ArrayMatcher.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright (c) 2001-2005 OFFIS. This program is made available under the terms of
 3    * the MIT License.
 4    */
 5    package org.easymock.internal;
 6   
 7    import java.lang.reflect.Array;
 8    import java.util.Arrays;
 9   
 10    import org.easymock.AbstractMatcher;
 11   
 12    public class ArrayMatcher extends AbstractMatcher {
 13  18 public String argumentToString(Object argument) {
 14  18 if (argument != null && argument.getClass().isArray()) {
 15  16 return arrayToString(createObjectArray(argument));
 16    } else {
 17  2 return super.argumentToString(argument);
 18    }
 19    }
 20   
 21  16 private String arrayToString(Object[] array) {
 22  16 StringBuffer result = new StringBuffer();
 23  16 for (int i = 0; i < array.length; i++) {
 24  28 result.append(super.argumentToString(array[i]));
 25  28 if (i != array.length - 1)
 26  12 result.append(", ");
 27    }
 28  16 return "[" + result.toString() + "]";
 29    }
 30   
 31  23 public boolean argumentMatches(Object expected, Object actual) {
 32  23 if (expected instanceof boolean[]) {
 33  2 return Arrays.equals((boolean[]) expected, (boolean[]) actual);
 34  21 } else if (expected instanceof byte[]) {
 35  2 return Arrays.equals((byte[]) expected, (byte[]) actual);
 36  19 } else if (expected instanceof char[]) {
 37  2 return Arrays.equals((char[]) expected, (char[]) actual);
 38  17 } else if (expected instanceof double[]) {
 39  2 return Arrays.equals((double[]) expected, (double[]) actual);
 40  15 } else if (expected instanceof float[]) {
 41  2 return Arrays.equals((float[]) expected, (float[]) actual);
 42  13 } else if (expected instanceof int[]) {
 43  4 return Arrays.equals((int[]) expected, (int[]) actual);
 44  9 } else if (expected instanceof long[]) {
 45  2 return Arrays.equals((long[]) expected, (long[]) actual);
 46  7 } else if (expected instanceof short[]) {
 47  2 return Arrays.equals((short[]) expected, (short[]) actual);
 48  5 } else if (expected instanceof Object[]) {
 49  3 return Arrays.equals((Object[]) expected, (Object[]) actual);
 50    } else {
 51  2 return super.argumentMatches(expected, actual);
 52    }
 53    }
 54   
 55  56 public static Object[] createObjectArray(Object array) {
 56  56 if (array instanceof Object[]) {
 57  16 return (Object[]) array;
 58    }
 59  40 Object[] result = new Object[Array.getLength(array)];
 60  40 for (int i = 0; i < Array.getLength(array); i++) {
 61  64 result[i] = Array.get(array, i);
 62    }
 63  40 return result;
 64    }
 65    }