Missed the other attachment.

-----Original Message-----
From: Nathan Beyer [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 31, 2005 4:21 PM
To: 'Jakarta Commons Developers List'
Subject: [lang][patch] Tests for math sub-package (was RE: [lang] Better
coverage for StrBuilder and StrTokenizer.)

Here are some additional patches for the 'math' sub-package. The second
attachment is a new test file, since there wasn't a file just for testing
the Range class's base methods.

-----Original Message-----
From: Gary Gregory [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 30, 2005 6:58 PM
To: Jakarta Commons Developers List
Subject: RE: [lang] Better coverage for StrBuilder and StrTokenizer.

As far as other areas, please look at the clover report [1] or generate
one yourself with Maven and feel free to up the %'s in any deficient
area.

Thanks,
Gary

[1] http://people.apache.org/~ggregory/commons-lang/2.2-dev/docs/clover

/*
 * Copyright 2002-2005 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.lang.math;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * <p>
 * <i>RangeTest</i> is a test of the base methods in the [EMAIL PROTECTED] 
org.apache.commons.lang.math.Range}  class.
 * </p>
 * @author Nathan Beyer
 * @version $Revision: $ $Date: $
 */
public class RangeTest extends TestCase {

    public static void main(String[] args) {
        junit.textui.TestRunner.run(RangeTest.class);
    }
    
    public static Test suite ( ) {
        TestSuite suite = new TestSuite (RangeTest.class);
        suite.setName("Range Tests");
        return suite;
    }

    public RangeTest(String name) {
        super(name);
    }

    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }
    
    private static class JUnitRange extends Range {
        private byte min;
        private byte max;
        JUnitRange (byte min, byte max) {
            super ();
            this.min = min;
            this.max = max;
        }
        public boolean containsNumber(Number number) {
                if (number.byteValue() >= min && number.byteValue() <= max) {
                    return true;
                }
                return false;
        }

        public Number getMaximumNumber() {
            return new Byte (max); 
        }

        public Number getMinimumNumber() {
            return new Byte (min);
        }
    }

    /*
     * Test method for 'org.apache.commons.lang.math.Range.hashCode()'
     */
    public void testHashCode() {
        JUnitRange r1 = new JUnitRange ((byte)0, (byte)5);
        JUnitRange r2 = new JUnitRange ((byte)0, (byte)5);
        JUnitRange r3 = new JUnitRange ((byte)0, (byte)10);
        
        assertEquals (r1.hashCode(), r2.hashCode());
        assertFalse(r1.hashCode() == r3.hashCode());
    }

    /*
     * Test method for 'org.apache.commons.lang.math.Range.equals(Object)'
     */
    public void testEqualsObject() {
        JUnitRange r1 = new JUnitRange ((byte)0, (byte)5);
        JUnitRange r2 = new JUnitRange ((byte)0, (byte)5);
        JUnitRange r3 = new JUnitRange ((byte)0, (byte)10);
        
        assertEquals(r1, r2);
        assertFalse(r2.equals(r3));
    }

    /*
     * Test method for 'org.apache.commons.lang.math.Range.toString()'
     */
    public void testToString() {
        JUnitRange r1 = new JUnitRange ((byte)0, (byte)5);
        assertNotNull (r1.toString());
        assertNotNull (r1.toString());
        JUnitRange r2 = new JUnitRange ((byte)0, (byte)5);
        assertNotNull (r2.toString());
        assertNotNull (r2.toString());
        JUnitRange r3 = new JUnitRange ((byte)0, (byte)10);
        assertNotNull (r3.toString());
        assertNotNull (r3.toString());
    }

}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to