Provides a few unit tests for ObjectRanges of Characters. More tests are needed.
| 29 | * Provides a few unit tests for {@link ObjectRange}s of {@link Character}s. More tests are needed. |
| 30 | */ |
| 31 | public class CharacterRangeTest extends TestCase { |
| 32 | /** |
| 33 | * The range to test. |
| 34 | */ |
| 35 | private ObjectRange range = null; |
| 36 | |
| 37 | /** |
| 38 | * The first character in the range. |
| 39 | */ |
| 40 | private final Character FROM = Character.valueOf('a'); |
| 41 | |
| 42 | /** |
| 43 | * The last character in the range. |
| 44 | */ |
| 45 | private final Character TO = Character.valueOf('d'); |
| 46 | |
| 47 | /** |
| 48 | * {@inheritDoc} |
| 49 | */ |
| 50 | protected void setUp() throws Exception { |
| 51 | super.setUp(); |
| 52 | range = new ObjectRange(FROM, TO); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Tests iterating through the range. |
| 57 | */ |
| 58 | public void testIterate() { |
| 59 | Iterator iter = range.iterator(); |
| 60 | assertEquals(FROM, iter.next()); |
| 61 | for (char expected = (char) (FROM.charValue() + 1); expected <= TO.charValue(); expected++) { |
| 62 | assertEquals(expected, ((Character)iter.next()).charValue()); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Tests getting the 'from' value. |
| 68 | */ |
| 69 | public void testGetFrom() { |
| 70 | assertEquals("wrong 'from' value", FROM, range.getFrom()); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Tests getting the 'to' value. |
| 75 | */ |
| 76 | public void testGetTo() { |
| 77 | assertEquals("wrong 'to' value", TO, range.getTo()); |
| 78 | } |
| 79 | |
| 80 | } |