avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject cvs commit: avalon/framework/api/src/test/org/apache/avalon/framework/test VersionTestCase.java EnumTestCase.java
Date Sun, 11 Jan 2004 22:34:26 GMT
leosimons    2004/01/11 14:34:26

  Modified:    framework/api/src/test/org/apache/avalon/framework/test
                        VersionTestCase.java EnumTestCase.java
  Log:
  100% coverage for Enum and Version.
  
  Revision  Changes    Path
  1.2       +33 -1     avalon/framework/api/src/test/org/apache/avalon/framework/test/VersionTestCase.java
  
  Index: VersionTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/framework/api/src/test/org/apache/avalon/framework/test/VersionTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VersionTestCase.java	11 Jan 2004 22:17:19 -0000	1.1
  +++ VersionTestCase.java	11 Jan 2004 22:34:26 -0000	1.2
  @@ -77,6 +77,16 @@
   
           final Version v3 = Version.getVersion( "78.10.03" );
           assertTrue( new Version( 78, 10, 3 ).equals( v3 ) );
  +
  +
  +        try
  +        {
  +            final Version v4 = Version.getVersion( null );
  +
  +            fail( "Expected an exception!" );
  +        }
  +        catch( NullPointerException th )
  +        {}
       }
   
       public void testInvalidVersionString()
  @@ -122,6 +132,8 @@
           assertTrue(   v3.complies( v1 ) );
           assertTrue( ! v1.complies( v4 ) );
           assertTrue( ! v4.complies( v1 ) );
  +
  +        assertTrue( ! v4.complies( null ) );
       }
       
       public void testHashCode()
  @@ -159,6 +171,26 @@
           
           assertEquals( -1, v3.compareTo(v4) );
           assertEquals( 1, v4.compareTo(v3) );
  +
  +        try
  +        {
  +            v4.compareTo(null);
  +            fail( "Expected an exception!" );
  +        }
  +        catch( NullPointerException th )
  +        {}
  +    }
  +
  +    public void testEquals()
  +    {
  +        assertFalse( new Version( 1, 0, 0 ).equals( this ) );
  +        assertFalse( new Version( 1, 0, 0 ).equals( null ) );
  +    }
  +
  +    public void testToString()
  +    {
  +        assertEquals( "1.0.0", new Version( 1, 0, 0 ).toString() );
  +        assertEquals( "230.21.-123456", new Version( 230, 21, -123456 ).toString() );
       }
   
       private int calculateHash(final Version v) {
  
  
  
  1.2       +15 -2     avalon/framework/api/src/test/org/apache/avalon/framework/test/EnumTestCase.java
  
  Index: EnumTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/framework/api/src/test/org/apache/avalon/framework/test/EnumTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EnumTestCase.java	11 Jan 2004 22:17:19 -0000	1.1
  +++ EnumTestCase.java	11 Jan 2004 22:34:26 -0000	1.2
  @@ -54,6 +54,7 @@
   import org.apache.avalon.framework.Enum;
   
   import java.util.Map;
  +import java.util.HashMap;
   
   /**
    * TestCase for {@link Enum}.
  @@ -105,7 +106,19 @@
       
       public void testConstructor()
       {
  -        assertNotNull( new Color( "blah", null) );
  +        assertNotNull( new Color( "blah", null ) );
  +
  +        Map entries = new HashMap();
  +
  +        Color c = new Color( "blah", entries );
  +
  +        assertTrue( entries.containsKey("blah") );
  +        assertTrue( entries.containsValue(c) );
  +
  +        OtherColor c2 = new OtherColor( "blah", entries );
  +        assertTrue( entries.containsKey("blah") );
  +        assertFalse( entries.containsValue(c) );
  +        assertTrue( entries.containsValue(c2) );
       }
   
       public void testEquals()
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message