EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.assertion]

COVERAGE SUMMARY FOR SOURCE FILE [ComparableTesterFactory.java]

nameclass, %method, %block, %line, %
ComparableTesterFactory.java100% (2/2)100% (6/6)59%  (114/194)66%  (19/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComparableTesterFactory100% (1/1)100% (2/2)100% (14/14)100% (5/5)
ComparableTesterFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newComparableTester (ObjectFactory): ComparableTester 100% (1/1)100% (11/11)100% (3/3)
     
class ComparableTesterFactory$ComparableTesterImpl100% (1/1)100% (4/4)56%  (100/180)58%  (14/24)
<static initializer> 100% (1/1)53%  (18/34)71%  (5/7)
ComparableTesterFactory$ComparableTesterImpl (ObjectFactory): void 100% (1/1)100% (6/6)100% (3/3)
equalComparesToZero (): boolean 100% (1/1)54%  (38/70)43%  (3/7)
notEqualNotComparesToZero (): boolean 100% (1/1)54%  (38/70)43%  (3/7)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.assertion;
12 
13import java.lang.reflect.Method;
14import java.lang.reflect.InvocationTargetException;
15 
16final class ComparableTesterFactory
17{
18    private static final String COMPARE_TO = "compareTo";
19 
20    private ComparableTesterFactory()
21    {
22 
23    }
24 
25    public static ComparableTester newComparableTester(final ObjectFactory<? extends java.lang.Comparable> factory) throws NullPointerException
26    {
27        if(factory == null)
28        {
29            throw new NullPointerException();
30        }
31 
32        return new ComparableTesterImpl(factory);
33    }
34 
35    private static final class ComparableTesterImpl implements ComparableTester
36    {
37        private static Method compareTo;
38 
39        static
40        {
41            try
42            {
43                compareTo = java.lang.Comparable.class.getMethod(ComparableTesterFactory.COMPARE_TO, Object.class);
44 
45                if(!compareTo.isAccessible())
46                {
47                    compareTo.setAccessible(true);
48                }
49            }
50            catch(NoSuchMethodException e)
51            {
52                throw new AssertionException(e.getMessage(), e);
53            }
54        }
55 
56        private final ObjectFactory<? extends java.lang.Comparable> factory;
57 
58        ComparableTesterImpl(final ObjectFactory<? extends java.lang.Comparable> factory)
59        {
60            this.factory = factory;
61        }
62 
63        public boolean equalComparesToZero() throws AssertionException
64        {
65            final java.lang.Comparable<?> x = factory.newInstanceX();
66            final java.lang.Comparable<?> y = factory.newInstanceY();
67 
68            try
69            {
70                return ((Integer)compareTo.invoke(x, x)) == 0 && ((Integer)compareTo.invoke(y, y)) == 0;
71            }
72            catch(IllegalAccessException e)
73            {
74                throw new AssertionException(e.getMessage(), e);
75            }
76            catch(InvocationTargetException e)
77            {
78                throw new AssertionException(e.getMessage(), e);
79            }
80        }
81 
82        public boolean notEqualNotComparesToZero() throws AssertionException
83        {
84            final java.lang.Comparable<?> x = factory.newInstanceX();
85            final java.lang.Comparable<?> y = factory.newInstanceY();
86 
87            try
88            {
89                return ((Integer)compareTo.invoke(x, y)) != 0 && ((Integer)compareTo.invoke(y, x)) != 0;
90            }
91            catch(IllegalAccessException e)
92            {
93                throw new AssertionException(e.getMessage(), e);
94            }
95            catch(InvocationTargetException e)
96            {
97                throw new AssertionException(e.getMessage(), e);
98            }
99        }
100    }
101}

[all classes][org.jtiger.assertion]
EMMA 2.0.5312 (C) Vladimir Roubtsov