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

📄 ozonesortedsettest.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.//// This file is// Copyright (C) 2003-@year@ Leo Mekenkamp. All rights reserved.// $Id: FullTreeMap.java,v 1.3 2003/02/02 17:21:41 leomekenkamp Exp $package org.ozoneDB.collections;import java.util.Iterator;import java.util.SortedSet;/** * <p>Tests functionality which is specific for SortedSet interfaces.</p> * <p>TODO: find some way to test persistency of SubSets</p> * @author <a href="mailto:ozoneATmekenkampD0Tcom">Leo Mekenkamp (mind the anti-sp@m)</a> */public abstract class OzoneSortedSetTest extends OzoneCollectionTest {        public OzoneSortedSetTest(String name) {        super(name);    }    public void compareResults(Object refResult, Object cmpResult) {        if (refResult instanceof SortedSet) {            SortedSet refSet = (SortedSet) refResult;            SortedSet cmpSet = (SortedSet) cmpResult;            assertTrue("returned SortedSets should match size; ref: " + refSet.size() +", cmp: " + cmpSet.size(),                     refSet.size() == cmpSet.size());            Iterator iRef = refSet.iterator();            Iterator iCmp = cmpSet.iterator();            while (iRef.hasNext()) {                assertTrue("returned SortedSets should have 'equal' contents",                         iRef.next().equals(iCmp.next()));            }        } else {            super.compareResults(refResult, cmpResult);        }    }    public void testFirst() {        compare("clear");        compare("first");        for (int i = 0; i < VALUES.length; i ++) {            compare("add", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("first");        }        for (int i = 0; i < VALUES.length; i++) {            compare("remove", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("first");        }    }    public void testHeadSet() {        compare("clear");        compare("headSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);        for (int i = 0; i < VALUES.length; i ++) {            compare("add", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("headSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);            compare("headSet", new Object[] {"-1"}, PARAM_OBJECT);            compare("headSet", new Object[] {"99999999"}, PARAM_OBJECT);        }        for (int i = 0; i < VALUES.length; i++) {            compare("contains", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("headSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);            compare("headSet", new Object[] {"-1"}, PARAM_OBJECT);            compare("headSet", new Object[] {"99999999"}, PARAM_OBJECT);        }    }    public void testLast() {        compare("clear");        compare("last");        for (int i = 0; i < VALUES.length; i ++) {            compare("add", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("last");        }        for (int i = 0; i < VALUES.length; i++) {            compare("remove", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("last");        }    }    public void testSubSet() {        compare("clear");        compare("subSet", new Object[] {"-1", VALUES[VALUES.length / 2]}, new Class[] {Object.class, Object.class});        for (int i = 0; i < VALUES.length; i ++) {            compare("add", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("subSet", new Object[] {VALUES[VALUES.length / 2], VALUES[2 + VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {VALUES[2 + VALUES.length / 2], VALUES[VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {"-1", VALUES[VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {"-1", "99999999"}, new Class[] {Object.class, Object.class});        }        for (int i = 0; i < VALUES.length; i++) {            compare("contains", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("subSet", new Object[] {VALUES[VALUES.length / 2], VALUES[2 + VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {VALUES[2 + VALUES.length / 2], VALUES[VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {"-1", VALUES[VALUES.length / 2]}, new Class[] {Object.class, Object.class});            compare("subSet", new Object[] {"-1", "99999999"}, new Class[] {Object.class, Object.class});        }    }    public void testTailSet() {        compare("clear");        compare("headSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);        for (int i = 0; i < VALUES.length; i ++) {            compare("add", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("tailSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);            compare("tailSet", new Object[] {"-1"}, PARAM_OBJECT);            compare("tailSet", new Object[] {"99999999"}, PARAM_OBJECT);        }        for (int i = 0; i < VALUES.length; i++) {            compare("contains", new Object[] {VALUES[i]}, PARAM_OBJECT);            compare("tailSet", new Object[] {VALUES[VALUES.length / 2]}, PARAM_OBJECT);            compare("tailSet", new Object[] {"-1"}, PARAM_OBJECT);            compare("tailSet", new Object[] {"99999999"}, PARAM_OBJECT);        }    }    }

⌨️ 快捷键说明

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