home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (CharacterRangeTest.java)

This example Groovy source code file (CharacterRangeTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

character, character, characterrangetest, exception, from, from, iterator, objectrange, objectrange, testcase, to, to, util

The Groovy CharacterRangeTest.java source code

/**
 *
 */
package groovy.lang;

import junit.framework.TestCase;

import java.util.Iterator;

/**
 * Provides a few unit tests for {@link ObjectRange}s of {@link Character}s.  More tests are needed.
 *
 * @author Edwin Tellman
 */
public class CharacterRangeTest extends TestCase {
    /**
     * The range to test.
     */
    private ObjectRange range = null;

    /**
     * The first character in the range.
     */
    private final Character FROM = new Character('a');

    /**
     * The last character in the range.
     */
    private final Character TO = new Character('d');

    /**
     * {@inheritDoc}
     */
    protected void setUp() throws Exception {
        super.setUp();
        range = new ObjectRange(FROM, TO);
    }

    /**
     * Tests iterating through the range.
     */
    public void testIterate() {
        Iterator iter = range.iterator();
        assertEquals(FROM, iter.next());
        for (char expected = (char) (FROM.charValue() + 1); expected <= TO.charValue(); expected++) {
            assertEquals(expected, ((Character)iter.next()).charValue());
        }
    }

    /**
     * Tests getting the 'from' value.
     */
    public void testGetFrom() {
        assertEquals("wrong 'from' value", FROM, range.getFrom());
    }

    /**
     * Tests getting the 'to' value.
     */
    public void testGetTo() {
        assertEquals("wrong 'to' value", TO, range.getTo());
    }

}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy CharacterRangeTest.java source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.