1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
// Tags: JDK1.2
// Copyright (C) 2003 Daniel Bonniot <bonniot@users.sf.net>
// 2004 David Gilbert <david.gilbert@object-refinery.com>
// This file is part of Mauve.
// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA. */
package gnu.testlet.java.util.Arrays;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
import java.util.Arrays;
public class equals implements Testlet
{
public void test (TestHarness harness)
{
final String[] a1 = { "", null };
final String[] a2 = { "", null };
harness.check(Arrays.equals(a1, a2));
// added by David Gilbert
testBoolean(harness);
testByte(harness);
testChar(harness);
testDouble(harness);
testFloat(harness);
testInt(harness);
testLong(harness);
testObject(harness);
testShort(harness);
}
private void testBoolean(TestHarness harness)
{
harness.checkPoint("Arrays.equals(boolean[], boolean[]");
harness.check(Arrays.equals((boolean[]) null, (boolean[]) null));
boolean[] b1 = new boolean[] {true, false};
boolean[] b2 = new boolean[] {true, false};
boolean[] b3 = new boolean[] {false, true};
boolean[] b4 = new boolean[] {true};
boolean[] b5 = new boolean[] {true, false, false};
boolean[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testByte(TestHarness harness)
{
harness.checkPoint("Arrays.equals(byte[], byte[]");
harness.check(Arrays.equals((byte[]) null, (byte[]) null));
byte[] b1 = new byte[] {1, 0};
byte[] b2 = new byte[] {1, 0};
byte[] b3 = new byte[] {0, 1};
byte[] b4 = new byte[] {1};
byte[] b5 = new byte[] {1, 0, 0};
byte[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testChar(TestHarness harness)
{
harness.checkPoint("Arrays.equals(char[], char[]");
harness.check(Arrays.equals((char[]) null, (char[]) null));
char[] b1 = new char[] {'1', '0'};
char[] b2 = new char[] {'1', '0'};
char[] b3 = new char[] {'0', '1'};
char[] b4 = new char[] {'1'};
char[] b5 = new char[] {'1', '0', '0'};
char[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testDouble(TestHarness harness)
{
harness.checkPoint("Arrays.equals(double[], double[]");
harness.check(Arrays.equals((double[]) null, (double[]) null));
double[] b1 = new double[] {1, 0};
double[] b2 = new double[] {1, 0};
double[] b3 = new double[] {0, 1};
double[] b4 = new double[] {1};
double[] b5 = new double[] {1, 0, 0};
double[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testFloat(TestHarness harness)
{
harness.checkPoint("Arrays.equals(float[], float[]");
harness.check(Arrays.equals((float[]) null, (float[]) null));
float[] b1 = new float[] {1, 0};
float[] b2 = new float[] {1, 0};
float[] b3 = new float[] {0, 1};
float[] b4 = new float[] {1};
float[] b5 = new float[] {1, 0, 0};
float[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testInt(TestHarness harness)
{
harness.checkPoint("Arrays.equals(int[], int[]");
harness.check(Arrays.equals((int[]) null, (int[]) null));
int[] b1 = new int[] {1, 0};
int[] b2 = new int[] {1, 0};
int[] b3 = new int[] {0, 1};
int[] b4 = new int[] {1};
int[] b5 = new int[] {1, 0, 0};
int[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testLong(TestHarness harness)
{
harness.checkPoint("Arrays.equals(long[], long[]");
harness.check(Arrays.equals((long[]) null, (long[]) null));
long[] b1 = new long[] {1, 0};
long[] b2 = new long[] {1, 0};
long[] b3 = new long[] {0, 1};
long[] b4 = new long[] {1};
long[] b5 = new long[] {1, 0, 0};
long[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
private void testObject(TestHarness harness)
{
harness.checkPoint("Arrays.equals(Object[], Object[]");
harness.check(Arrays.equals((Object[]) null, (Object[]) null));
Object[] b1 = new Object[] {"1", "0", null};
Object[] b2 = new Object[] {"1", "0", null};
Object[] b3 = new Object[] {"0", "1"};
Object[] b4 = new Object[] {"1"};
Object[] b5 = new Object[] {"1", "0", "0"};
Object[] b6 = new Object[] {"1", "0", null, "0"};
Object[] b7 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
harness.check(!Arrays.equals(b1, b7));
}
private void testShort(TestHarness harness)
{
harness.checkPoint("Arrays.equals(short[], short[]");
harness.check(Arrays.equals((short[]) null, (short[]) null));
short[] b1 = new short[] {1, 0};
short[] b2 = new short[] {1, 0};
short[] b3 = new short[] {0, 1};
short[] b4 = new short[] {1};
short[] b5 = new short[] {1, 0, 0};
short[] b6 = null;
harness.check(Arrays.equals(b1, b2));
harness.check(!Arrays.equals(b1, b3));
harness.check(!Arrays.equals(b1, b4));
harness.check(!Arrays.equals(b1, b5));
harness.check(!Arrays.equals(b1, b6));
}
}
|