//
// $Id$
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001-2010 Michael Bayne, et al.
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.samskivert.util.tests;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import junit.framework.Test;
import junit.framework.TestCase;

import com.samskivert.util.CollectionUtil;
import com.samskivert.util.ComparableArrayList;
import com.samskivert.util.StringUtil;

/**
 * Tests the {@link CollectionUtil} class.
 */
public class CollectionUtilTest extends TestCase
{
    public CollectionUtilTest ()
    {
        super(CollectionUtil.class.getName());
    }

    @Override
    public void runTest ()
    {
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 100; i++) {
            list.add(i);
        }

        for (int i = 0; i < 10; i++) {
            List<Integer> subset = CollectionUtil.selectRandomSubset(list, 10);
            // System.out.println(StringUtil.toString(subset));
            assertTrue("length == 10", subset.size() == 10);
        }

        // test comparable array list insertion
        Random rand = new Random();
        ComparableArrayList<Integer> slist = new ComparableArrayList<Integer>();
        for (int ii = 0; ii < 25; ii++) {
            slist.insertSorted(rand.nextInt(100));
        }
        System.out.println(StringUtil.toString(slist));
    }

    public static Test suite ()
    {
        return new CollectionUtilTest();
    }

    public static void main (String[] args)
    {
        CollectionUtilTest test = new CollectionUtilTest();
        test.runTest();
    }
}

@@ -964,25 +964,24 @@
 Random;%0A
-%0A
 import j
 unit.fra
@@ -976,36 +976,38 @@
 rt j
-unit.framework.Test;
+ava.util.Collections;%0A
 %0Aimport 
 juni
@@ -1006,32 +1006,53 @@
 ort 
+org.
 junit.
-framework.TestCase
+*;%0Aimport static org.junit.Assert.*
 ;%0A%0Ai
@@ -1267,157 +1267,54 @@
 Test
- extends TestCase
 %0A%7B%0A    
+@Test 
 public 
-CollectionUtilTest ()%0A    %7B%0A        super(CollectionUtil.class.getName());%0A    %7D%0A%0A    @Override%0A    public void runTes
+void testSelectRandomSubse
 t ()
@@ -1702,32 +1702,86 @@
  10);%0A        %7D%0A
+    %7D%0A%0A    @Test public void testInsertSorted ()%0A    %7B
 %0A        // test
@@ -2045,282 +2045,121 @@
     
-System.out.println(StringUtil.toString(slist));%0A    %7D%0A%0A    public static Test suite ()%0A    %7B%0A        return new CollectionUtilTest();%0A    %7D%0A%0A    public static void main (String%5B%5D args)%0A    %7B%0A        CollectionUtilTest test = new CollectionUtilTest();%0A        test.runTest();
+for (int ii = 0; ii %3C slist.size()-1; ii++) %7B%0A            assertTrue(slist.get(ii) %3C= slist.get(ii+1));%0A        %7D
 %0A   

Switch to JUnit4 style.