From lucene-dev-return-1707-qmlist-jakarta-archive-lucene-dev=jakarta.apache.org@jakarta.apache.org Wed Jun 05 01:51:00 2002 Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 34519 invoked from network); 5 Jun 2002 01:51:00 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 5 Jun 2002 01:51:00 -0000 Received: (qmail 27374 invoked by uid 97); 5 Jun 2002 01:51:09 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org Received: (qmail 27320 invoked by uid 97); 5 Jun 2002 01:51:08 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 27309 invoked by uid 97); 5 Jun 2002 01:51:08 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 5 Jun 2002 01:50:54 -0000 Message-ID: <20020605015054.65321.qmail@icarus.apache.org> From: otis@apache.org To: jakarta-lucene-cvs@apache.org Subject: cvs commit: jakarta-lucene/src/test/org/apache/lucene/util TestPriorityQueue.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N otis 2002/06/04 18:50:54 Modified: src/test/org/apache/lucene/util TestPriorityQueue.java Log: - Added testClear() test. It doesn't really test much, but since I already typed it in I'm leaving it. - Reformatted/reindented the code and nuked trailing spaces. Revision Changes Path 1.3 +68 -46 jakarta-lucene/src/test/org/apache/lucene/util/TestPriorityQueue.java Index: TestPriorityQueue.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/util/TestPriorityQueue.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestPriorityQueue.java 28 Jan 2002 20:25:21 -0000 1.2 +++ TestPriorityQueue.java 5 Jun 2002 01:50:54 -0000 1.3 @@ -56,61 +56,83 @@ import java.util.Date; import java.util.Random; -import junit.framework.*; +import junit.framework.TestCase; -public class TestPriorityQueue extends TestCase { - public TestPriorityQueue(String name) { - super(name); - } - - private static class IntegerQueue extends PriorityQueue { - public IntegerQueue(int count) { - super(); - initialize(count); +public class TestPriorityQueue + extends TestCase +{ + public TestPriorityQueue(String name) + { + super(name); } - protected boolean lessThan(Object a, Object b) { - return ((Integer) a).intValue() < ((Integer) b).intValue(); + private static class IntegerQueue + extends PriorityQueue + { + public IntegerQueue(int count) + { + super(); + initialize(count); + } + + protected boolean lessThan(Object a, Object b) + { + return ((Integer) a).intValue() < ((Integer) b).intValue(); + } } - } - public void testPQ() throws Exception { - testPQ(10000); - } - - public static void testPQ(int count) { - PriorityQueue pq = new IntegerQueue(count); - Random gen = new Random(); - int sum = 0, sum2 = 0; - - Date start = new Date(); - - for (int i = 0; i < count; i++) { - int next = gen.nextInt(); - sum += next; - pq.put(new Integer(next)); + public void testPQ() + throws Exception + { + testPQ(10000); } -// Date end = new Date(); + public static void testPQ(int count) + { + PriorityQueue pq = new IntegerQueue(count); + Random gen = new Random(); + int sum = 0, sum2 = 0; + + Date start = new Date(); + + for (int i = 0; i < count; i++) + { + int next = gen.nextInt(); + sum += next; + pq.put(new Integer(next)); + } + + // Date end = new Date(); + + // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); + // System.out.println(" microseconds/put"); + + // start = new Date(); + + int last = Integer.MIN_VALUE; + for (int i = 0; i < count; i++) + { + Integer next = (Integer)pq.pop(); + assertTrue(next.intValue() >= last); + last = next.intValue(); + sum2 += last; + } -// System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); -// System.out.println(" microseconds/put"); + assertEquals(sum, sum2); + // end = new Date(); -// start = new Date(); - - int last = Integer.MIN_VALUE; - for (int i = 0; i < count; i++) { - Integer next = (Integer)pq.pop(); - assertTrue(next.intValue() >= last); - last = next.intValue(); - sum2 += last; + // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); + // System.out.println(" microseconds/pop"); } - assertEquals(sum, sum2); -// end = new Date(); - -// System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); -// System.out.println(" microseconds/pop"); - - } + public void testClear() + { + PriorityQueue pq = new IntegerQueue(3); + pq.put(new Integer(2)); + pq.put(new Integer(3)); + pq.put(new Integer(1)); + assertEquals(3, pq.size()); + pq.clear(); + assertEquals(0, pq.size()); + } } -- To unsubscribe, e-mail: For additional commands, e-mail: