EMMA Coverage Report (generated Mon Jul 11 13:15:38 KST 2005)
[all classes][org.apache.mina.util]

COVERAGE SUMMARY FOR SOURCE FILE [QueueTest.java]

nameclass, %method, %block, %line, %
QueueTest.java100% (1/1)83%  (5/6)90%  (102/113)91%  (19.9/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QueueTest100% (1/1)83%  (5/6)90%  (102/113)91%  (19.9/22)
main (String []): void 0%   (0/1)0%   (0/10)0%   (0/2)
testExpandingRotation (): void 100% (1/1)98%  (47/48)99%  (8.9/9)
QueueTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (7/7)100% (3/3)
testRotation (): void 100% (1/1)100% (8/8)100% (3/3)
testRotation0 (Queue): void 100% (1/1)100% (37/37)100% (4/4)

1/*
2 *   @(#) $Id: QueueTest.java 210062 2005-07-11 03:52:38Z trustin $
3 *
4 *   Copyright 2004 The Apache Software Foundation
5 *
6 *   Licensed under the Apache License, Version 2.0 (the "License");
7 *   you may not use this file except in compliance with the License.
8 *   You may obtain a copy of the License at
9 *
10 *       http://www.apache.org/licenses/LICENSE-2.0
11 *
12 *   Unless required by applicable law or agreed to in writing, software
13 *   distributed under the License is distributed on an "AS IS" BASIS,
14 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 *   See the License for the specific language governing permissions and
16 *   limitations under the License.
17 *
18 */
19package org.apache.mina.util;
20 
21import junit.framework.Assert;
22import junit.framework.TestCase;
23 
24/**
25 * Tests {@link Queue}
26 * 
27 * @author The Apache Directory Project (dev@directory.apache.org)
28 * @author Trustin Lee (trustin@apache.org)
29 * @version $Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
30 */
31public class QueueTest extends TestCase
32{
33    private int pushCount;
34    private int popCount;
35    
36    public void setUp()
37    {
38        pushCount = 0;
39        popCount = 0;
40    }
41 
42    public void testRotation()
43    {
44        Queue q = new Queue(); // DEFAULT_CAPACITY = 4
45        testRotation0( q );
46    }
47    
48    public void testExpandingRotation()
49    {
50        Queue q = new Queue(); // DEFAULT_CAPACITY = 4
51        for( int i = 0; i < 10; i ++ )
52        {
53            testRotation0( q );
54 
55            // make expansion happen
56            int oldCapacity = q.capacity();
57            for( int j = q.capacity(); j >= 0; j-- )
58            {
59                q.push( new Integer( ++pushCount ) );
60            }
61            
62            Assert.assertTrue( q.capacity() > oldCapacity );
63            testRotation0( q );
64        }
65    }
66    
67    private void testRotation0( Queue q )
68    {
69        for( int i = 0; i < q.capacity() * 7 / 4; i ++ )
70        {
71            q.push( new Integer( ++pushCount ) );
72            Assert.assertEquals( ++popCount, ( ( Integer ) q.pop() ).intValue() );
73        }
74    }
75    
76    public static void main( String[] args )
77    {
78        junit.textui.TestRunner.run( QueueTest.class );
79    }
80}

[all classes][org.apache.mina.util]
EMMA 2.0.4217 (C) Vladimir Roubtsov