Package programming5.arrays

Examples of programming5.arrays.ArrayOperationsTest


    protected RandomIndexGenerator alphabeticMixedCaseRandom;
    protected Random lengthRandom;

    public RandomStringGenerator() {
        lengthRandom = new Random(System.currentTimeMillis());
        generalRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "32-126");   // TODO: What is a good code range for all?
        numericRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57");
        alphanumericRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57, 97-122");
        alphabeticRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "97 - 122");
        alphanumericMixedCaseRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57, 97-122, 65-90");
        alphabeticMixedCaseRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "65-90, 97-122");
    }
View Full Code Here


    /**
     * @param seed seed for random number generators
     */
    public RandomStringGenerator(long seed) {
        lengthRandom = new Random(seed);
        generalRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "32-126");
        numericRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57");
        alphanumericRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57, 97-122");
        alphabeticRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "97 - 122");
        alphanumericMixedCaseRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "48-57, 97-122, 65-90");
        alphabeticMixedCaseRandom = new RandomIndexGenerator(lengthRandom.nextLong(), "65-90, 97-122");
    }
View Full Code Here

        }
        int[][] aux = new int[ranges.length][];
        for (int i = 0; i < ranges.length; i++) {
            aux[i] = (int[]) ranges[i];
        }
        RandomIndexGenerator customRandom = new RandomIndexGenerator(lengthRandom.nextLong(), aux);
        // Generate string
        String ret = "";
        for (int i = 0; i < length; i++) {
            ret += Character.toString((char) customRandom.getRandomIndex());
        }
        return ret;
    }
View Full Code Here

    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        df = new KeyboardCharDistanceFunction();
        RandomIndexGenerator rig = new RandomIndexGenerator("32-126");
        arbitrary1 = (char) rig.getRandomIndex();
        arbitrary2 = (char) rig.getRandomIndex();
        arbitrary3 = (char) rig.getRandomIndex();
    }
View Full Code Here

    public void testReplicate_ReplicableType() {
        ReplicableObject[] toReplicate = new ReplicableObject[0];
        ReplicableObject[] replica = new ReplicableObject[0];
        ArrayOperations.replicate(toReplicate, replica);
        assertEquals(0, replica.length);
        ReplicableObject one = new ReplicableObject(1);
        toReplicate = new ReplicableObject[] {one};
        replica = new ReplicableObject[1];
        ArrayOperations.replicate(toReplicate, replica);
        assertNotSame(replica, toReplicate);
        assertNotSame(replica[0], toReplicate[0]);
        assertArrayEquals(new ReplicableObject[] {one}, replica);
        ReplicableObject two = new ReplicableObject(2);
        ReplicableObject three = new ReplicableObject(3);
        toReplicate = new ReplicableObject[] {one, two, three};
        replica = new ReplicableObject[3];
        ArrayOperations.replicate(toReplicate, replica);
        two.setField(20);
        assertEquals(20, toReplicate[1].getField());
View Full Code Here

    /**
     * Test of prefix method, of class ArrayOperations.
     */
    @Test
    public void testPrefix_ObjectArr_int() {
        ReplicableObject one = new ReplicableObject(1);
        ReplicableObject two = new ReplicableObject(2);
        ReplicableObject three = new ReplicableObject(3);
        ReplicableObject[] toPrefix = new ReplicableObject[] {one, two, three};
        Object[] prefix = ArrayOperations.prefix(toPrefix, 0);
        assertEquals(0, prefix.length);
        prefix = ArrayOperations.prefix(toPrefix, 2);
        assertEquals(2, prefix.length);
View Full Code Here

    /**
     * Test of suffix method, of class ArrayOperations.
     */
    @Test
    public void testSuffix_ObjectArr_int() {
        ReplicableObject one = new ReplicableObject(1);
        ReplicableObject two = new ReplicableObject(2);
        ReplicableObject three = new ReplicableObject(3);
        ReplicableObject[] toSuffix = new ReplicableObject[] {one, two, three};
        Object[] suffix = ArrayOperations.suffix(toSuffix, 0);
        assertEquals(3, suffix.length);
        assertArrayEquals(new ReplicableObject[] {one, two, three}, suffix);
        suffix = ArrayOperations.suffix(toSuffix, 2);
View Full Code Here

    /**
     * Test of subArray method, of class ArrayOperations.
     */
    @Test
    public void testSubArray_3args_7() {
        ReplicableObject one = new ReplicableObject(1);
        ReplicableObject two = new ReplicableObject(2);
        ReplicableObject three = new ReplicableObject(3);
        ReplicableObject[] toCut = new ReplicableObject[] {one, two, three};
        Object[] subArray = ArrayOperations.subArray(toCut, 0, 3);
        assertEquals(3, subArray.length);
        assertArrayEquals(new ReplicableObject[] {one, two, three}, subArray);
        subArray = ArrayOperations.subArray(toCut, 1, 2);
View Full Code Here

    /**
     * Test of join method, of class ArrayOperations.
     */
    @Test
    public void testJoin_ObjectArrArr() {
        ReplicableObject one = new ReplicableObject(1);
        ReplicableObject two = new ReplicableObject(2);
        ReplicableObject three = new ReplicableObject(3);
        ReplicableObject[] empty = new ReplicableObject[0];
        ReplicableObject[] single = new ReplicableObject[] {one};
        ReplicableObject[] multiple = new ReplicableObject[] {one, two, three};
        Object[] joined = ArrayOperations.join(empty);
        assertEquals(0, joined.length);
View Full Code Here

        int ret = ArrayOperations.seqFind(tag, args);
        if (ret >= 0) {
            return ret;
        }
        else {
            throw new NotFoundException();
        }
    }
View Full Code Here

TOP

Related Classes of programming5.arrays.ArrayOperationsTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.