From: Bryan T. <tho...@us...> - 2007-11-30 21:54:17
|
Update of /cvsroot/cweb/generic-native/src/test/org/CognitiveWeb/generic/core/ndx In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29240/src/test/org/CognitiveWeb/generic/core/ndx Added Files: TestComparators.java Log Message: Work on the bigdata-GOM integration. --- NEW FILE: TestComparators.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Jan 29, 2007 */ package org.CognitiveWeb.generic.core.ndx; import java.util.Arrays; import java.util.Comparator; import junit.framework.TestCase; /** * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class TestComparators extends TestCase { /** * */ public TestComparators() { } /** * @param arg0 */ public TestComparators(String arg0) { super(arg0); } public void test_intComparator() { final int lmin = Integer.MIN_VALUE; final int lm1 = -1; final int l0 = 0; final int lp1 = 1; final int lmax = Integer.MAX_VALUE; // values out of order. Integer[] vals = new Integer[] {lmax,lm1,lmin,l0,lp1}; Comparator c = new IntegerComparator(); System.err.println("unsorted values: "+Arrays.toString(vals)); Arrays.sort(vals); System.err.println("sorted values : "+Arrays.toString(vals)); assertTrue("kmin<km1", c.compare(lmin, lm1) < 0); assertTrue("km1<k0", c.compare(lm1, l0) < 0); assertTrue("k0<kp1", c.compare(l0, lp1) < 0); assertTrue("kp1<kmax", c.compare(lp1, lmax) < 0); assertTrue("kmin<kmax", c.compare(lmin, lmax) < 0); } public void test_longComparator() { final long lmin = Long.MIN_VALUE; final long lm1 = -1L; final long l0 = 0L; final long lp1 = 1L; final long lmax = Long.MAX_VALUE; // values out of order. Long[] vals = new Long[] {lmax,lm1,lmin,l0,lp1}; Comparator c = new LongComparator(); System.err.println("unsorted values: "+Arrays.toString(vals)); Arrays.sort(vals); System.err.println("sorted values : "+Arrays.toString(vals)); assertTrue("kmin<km1", c.compare(lmin, lm1) < 0); assertTrue("km1<k0", c.compare(lm1, l0) < 0); assertTrue("k0<kp1", c.compare(l0, lp1) < 0); assertTrue("kp1<kmax", c.compare(lp1, lmax) < 0); assertTrue("kmin<kmax", c.compare(lmin, lmax) < 0); } } |