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

COVERAGE SUMMARY FOR SOURCE FILE [HashCodeMethodContractTesterFactory.java]

nameclass, %method, %block, %line, %
HashCodeMethodContractTesterFactory.java100% (2/2)100% (6/6)100% (89/89)100% (20/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HashCodeMethodContractTesterFactory100% (1/1)100% (2/2)100% (14/14)100% (5/5)
HashCodeMethodContractTesterFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newHashCodeMethodContractTester (ObjectFactory): HashCodeMethodContractTester 100% (1/1)100% (11/11)100% (3/3)
     
class HashCodeMethodContractTesterFactory$HashCodeMethodContractTesterImpl100% (1/1)100% (4/4)100% (75/75)100% (15/15)
HashCodeMethodContractTesterFactory$HashCodeMethodContractTesterImpl (ObjectF... 100% (1/1)100% (6/6)100% (3/3)
fillsContract (): boolean 100% (1/1)100% (10/10)100% (1/1)
isConsistentResult (): boolean 100% (1/1)100% (29/29)100% (6/6)
isEqualOnEqualInstance (): boolean 100% (1/1)100% (30/30)100% (5/5)

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 
13final class HashCodeMethodContractTesterFactory
14{
15    private HashCodeMethodContractTesterFactory()
16    {
17 
18    }
19 
20    static HashCodeMethodContractTester newHashCodeMethodContractTester(final ObjectFactory<?> factory) throws NullPointerException
21    {
22        if(factory == null)
23        {
24            throw new NullPointerException();
25        }
26 
27        return new HashCodeMethodContractTesterImpl(factory);
28    }
29 
30    private static final class HashCodeMethodContractTesterImpl implements HashCodeMethodContractTester
31    {
32        private final ObjectFactory<?> factory;
33 
34        HashCodeMethodContractTesterImpl(final ObjectFactory<?> factory)
35        {
36            this.factory = factory;
37        }
38 
39        public boolean isConsistentResult()
40        {
41            for(int i = 0; i < 20; i++)
42            {
43                final Object x = factory.newInstanceX();
44                final Object y = factory.newInstanceY();
45 
46                if(!(x.hashCode() == x.hashCode() && y.hashCode() == y.hashCode()))
47                {
48                    return false;
49                }
50            }
51 
52            return true;
53        }
54 
55        public boolean isEqualOnEqualInstance()
56        {
57            final Object x1 = factory.newInstanceX();
58            final Object x2 = factory.newInstanceX();
59            final Object y1 = factory.newInstanceY();
60            final Object y2 = factory.newInstanceY();
61 
62            return x1.hashCode() == x2.hashCode() && y1.hashCode() == y2.hashCode();
63        }
64 
65        public boolean fillsContract()
66        {
67            return isConsistentResult() && isEqualOnEqualInstance();
68        }
69    }
70}

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