Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
../../../img/srcFileCovDistChart10.png 0% of files have more coverage
20   86   14   2,22
10   51   0,7   9
9     1,56  
1    
 
  Range       Line # 24 20 0% 14 0 100% 1.0
 
  (506)
 
1    /**
2    * Copyright 2001-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16   
17    package org.easymock.internal;
18   
19    import java.io.Serializable;
20   
21    /**
22    * @author OFFIS, Tammo Freese
23    */
 
24    public class Range implements Serializable {
25   
26    private static final long serialVersionUID = -6743402320315331536L;
27   
28    private final int minimum;
29   
30    private final int maximum;
31   
 
32  80 toggle public Range(final int count) {
33  80 this(count, count);
34    }
35   
 
36  2112 toggle public Range(final int minimum, final int maximum) {
37  2112 if (!(minimum <= maximum)) {
38  2 throw new RuntimeExceptionWrapper(new IllegalArgumentException("minimum must be <= maximum"));
39    }
40   
41  2110 if (!(minimum >= 0)) {
42  2 throw new RuntimeExceptionWrapper(new IllegalArgumentException("minimum must be >= 0"));
43    }
44   
45  2108 if (!(maximum >= 1)) {
46  2 throw new RuntimeExceptionWrapper(new IllegalArgumentException("maximum must be >= 1"));
47    }
48  2106 this.minimum = minimum;
49  2106 this.maximum = maximum;
50    }
51   
 
52  322 toggle public boolean hasFixedCount() {
53  322 return minimum == maximum;
54    }
55   
 
56  6734 toggle public int getMaximum() {
57  6734 return maximum;
58    }
59   
 
60  2184 toggle public int getMinimum() {
61  2184 return minimum;
62    }
63   
 
64  234 toggle @Override
65    public String toString() {
66  234 if (hasFixedCount()) {
67  202 return "" + minimum;
68  32 } else if (hasOpenCount()) {
69  20 return "at least " + minimum;
70    } else {
71  12 return "between " + minimum + " and " + maximum;
72    }
73    }
74   
 
75  234 toggle public String expectedCount() {
76  234 return "expected: " + this.toString();
77    }
78   
 
79  1748 toggle public boolean contains(final int count) {
80  1748 return minimum <= count && count <= maximum;
81    }
82   
 
83  7176 toggle public boolean hasOpenCount() {
84  7176 return maximum == Integer.MAX_VALUE;
85    }
86    }