From a33961018a058d253f76fc6e6de382b1074480ce Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Sun, 19 Dec 2004 03:23:00 +0000 Subject: [PATCH] few more tests to get 100% coverage for Token git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137999 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/time/DurationFormatUtilsTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java b/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java index 3cffa60c9..cf7becf28 100644 --- a/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java +++ b/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java @@ -318,6 +318,18 @@ public class DurationFormatUtilsTest extends TestCase { }, DurationFormatUtils.lexx(DurationFormatUtils.ISO_EXTENDED_FORMAT_PATTERN) ); + + // test failures in equals + DurationFormatUtils.Token token = new DurationFormatUtils.Token( DurationFormatUtils.y, 4 ); + assertFalse( "Token equal to non-Token class. ", token.equals(new Object()) ); + assertFalse( "Token equal to Token with wrong value class. ", token.equals( + new DurationFormatUtils.Token( new Object() ) + ) ); + assertFalse( "Token equal to Token with different count. ", token.equals( + new DurationFormatUtils.Token( new Object(), 1 ) + ) ); + DurationFormatUtils.Token numToken = new DurationFormatUtils.Token( new Integer(1), 4 ); + assertTrue( "Token with Number value not equal to itself. ", numToken.equals( numToken ) ); } private void assertArrayEquals(DurationFormatUtils.Token[] obj1, DurationFormatUtils.Token[] obj2) { assertEquals( "Arrays are unequal length. ", obj1.length, obj2.length );