⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collectiontest.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: CollectionTest.java,v 1.5 2000/10/28 16:55:15 daniela Exp $package org.ozoneDB.DxLib.test;import java.lang.*;import java.util.*;import org.ozoneDB.DxLib.*;/** *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.5 $Date: 2000/10/28 16:55:15 $ */public class CollectionTest extends AbstractTest {        final static int SIZE = Test.SIZE;            /**     */    public static Object[] newStrings() {        Object[] objs = new Object[SIZE];        for (int i = 0; i < SIZE; i++) {            objs[i] = String.valueOf( i );        }         return objs;    }             /**     */    public static Object[] newIntegers() {        Object[] objs = new Object[SIZE];        for (int i = 0; i < SIZE; i++) {            objs[i] = new Integer( i );        }         return objs;    }             /**     */    public static Object[] newDxStrings() {        Object[] objs = new Object[SIZE];        for (int i = 0; i < SIZE; i++) {            objs[i] = new DxString( String.valueOf( i ) );        }         return objs;    }             /**     */    public void add_iterate( DxCollection coll, Object[] objs ) throws Exception {        startTimer( coll.getClass().getName(), "add_iterate" );        for (int i = 0; i < objs.length; i++) {            coll.add( objs[i] );        }         stopTimer();                DxIterator it = coll.iterator();        while (it.next() != null) {            boolean found = false;            Object obj = it.object();            for (int j = 0; j < SIZE; j++) {                if (obj == objs[j]) {                    found = true;                }             }             if (!found) {                error();            }         }         stopTimer();    }             /**     */    public void contains( DxCollection coll, Object[] objs ) throws Exception {        for (int i = 0; i < objs.length; i++) {            coll.add( objs[i] );        }         startTimer( coll.getClass().getName(), "contains" );                for (int i = 0; i < SIZE; i++) {            if (!coll.contains( objs[i] )) {                error();            }         }         stopTimer();    }             /**     */    public void containsAll( DxCollection coll, Object[] objs ) throws Exception {        for (int i = 0; i < objs.length; i++) {            coll.add( objs[i] );        }         DxBag bag = new DxArrayBag();        bag.addAll( objs );        startTimer( coll.getClass().getName(), "containsAll" );                if (!coll.containsAll( bag )) {            error();        }                 if (!coll.containsAll( new DxArrayBag() )) {            error();        }                 DxBag emptyBag = new DxArrayBag();        if (emptyBag.containsAll( coll )) {            error();        }                 stopTimer();    }             /**     */    public void removeAll( DxCollection coll, Object[] objs ) throws Exception {        coll.addAll( objs );        startTimer( coll.getClass().getName(), "removeAll" );                DxBag bag = new DxArrayBag();        bag.addAll( objs );                coll.removeAll( bag );                if (coll.contains( objs[0] ) || !coll.isEmpty() || coll.count() != 0) {            error();        }                 stopTimer();    }             /**     */    public void remove_count_isEmpty( DxCollection coll, Object[] objs ) throws Exception {        startTimer( coll.getClass().getName(), "remove_count_isEmpty" );        if (!coll.isEmpty()) {            error();        }         if (coll.count() != 0) {            error();        }                 coll.addAll( objs );                coll.remove( objs[0] );        coll.remove( objs[2] );        //        coll.remove (objs[50].clone());                if (coll.count() != (SIZE - 3)) {            error();        }         if (coll.isEmpty()) {            error();        }                 if (coll.contains( objs[0] )) {            error();        }         if (coll.contains( objs[2] )) {            error();        }         if (coll.contains( objs[50] )) {            error();        }         if (!coll.contains( objs[1] )) {            error();        }         stopTimer();    }             /**     */    public void equals( DxCollection coll1, DxCollection coll2, Object[] objs ) throws Exception {        coll1.addAll( objs );        if (coll1.equals( coll2 )) {            error();        }                 coll2.addAll( objs );        startTimer( coll1.getClass().getName(), "equals" );                if (!coll1.equals( coll2 )) {            error();        }                 coll2.remove( objs[0] );        if (coll1.equals( coll2 )) {            error();        }                 stopTimer();    }             /**     */    public void toArray_clone_clear( DxCollection coll, Object[] objs ) {        coll.addAll( objs );        DxCollection clone = (DxCollection)coll.clone();        if (!coll.equals( clone )) {            error();        }                 startTimer( coll.getClass().getName(), "toArray" );                Object[] array = coll.toArray();        stopTimer();                coll.clear();        if (coll.equals( clone )) {            error();        }                 coll.addAll( array );        if (!coll.equals( clone )) {            error();        }     }     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -