ozeigermann 2004/06/11 05:33:18 Added: test/src/java/org/apache/commons/test/collection CollectionTest.java Log: Added initial version of collection test helpers Revision Changes Path 1.1 jakarta-commons-sandbox/test/src/java/org/apache/commons/test/collection/CollectionTest.java Index: CollectionTest.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/test/src/java/org/apache/commons/test/collection/CollectionTest.java,v 1.1 2004/06/11 12:33:18 ozeigermann Exp $ * $Revision: 1.1 $ * $Date: 2004/06/11 12:33:18 $ * * ==================================================================== * * Copyright 1999-2002 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.commons.test.collection; import java.util.Collection; import java.util.Iterator; import junit.framework.*; /** * Tests helpers for collections. * * @author <a href="mailto:[EMAIL PROTECTED]">Oliver Zeigermann</a> */ public class CollectionTest { public static void checkCollection(Collection col, Object[] values) { int trueCnt = 0; if (col.size() != values.length) { TestCase.fail("Collection and values do not have the same size"); } for (Iterator it = col.iterator(); it.hasNext();) { Object value1 = it.next(); for (int i = 0; i < values.length; i++) { Object value2 = values[i]; if (value2.equals(value1)) trueCnt++; } } if (trueCnt != values.length) { Object[] colValues = col.toArray(new Object[col.size()]); TestCase.fail("Collection " + colValues + " does not have the same values as " + values); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]