Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
27   78   14   4,5
12   60   0,52   6
6     2,33  
1    
 
 
  Results       Line # 12 27 14 100% 1.0
 
  (187)
 
1    /*
2    * Copyright (c) 2001-2008 OFFIS, Tammo Freese.
3    * This program is made available under the terms of the MIT License.
4    */
5    package org.easymock.internal;
6   
7    import java.io.Serializable;
8    import java.util.ArrayList;
9    import java.util.LinkedList;
10    import java.util.List;
11   
 
12    public class Results implements Serializable {
13   
14    private static final long serialVersionUID = -2722051869610289637L;
15   
16    private int callCount;
17   
18    private LinkedList<Range> ranges = new LinkedList<Range>();
19   
20    private List<Result> results = new ArrayList<Result>();
21   
 
22  439 toggle public void add(Result result, Range range) {
23  439 if (!ranges.isEmpty()) {
24  38 Range lastRange = ranges.getLast();
25  38 if (!lastRange.hasFixedCount())
26  2 throw new RuntimeExceptionWrapper(
27    new IllegalStateException(
28    "last method called on mock already has a non-fixed count set."));
29    }
30  437 ranges.add(range);
31  437 results.add(result);
32    }
33   
 
34  496 toggle public Result next() {
35  496 int currentPosition = 0;
36  615 for (int i = 0; i < ranges.size(); i++) {
37  576 Range interval = ranges.get(i);
38  576 if (interval.hasOpenCount()) {
39  52 callCount += 1;
40  52 return results.get(i);
41    }
42  524 currentPosition += interval.getMaximum();
43  524 if (currentPosition > callCount) {
44  405 callCount += 1;
45  405 return results.get(i);
46    }
47    }
48  39 return null;
49    }
50   
 
51  1091 toggle public boolean hasValidCallCount() {
52  1091 return getMainInterval().contains(getCallCount());
53    }
54   
 
55  239 toggle @Override
56    public String toString() {
57  239 return getMainInterval().expectedAndActual(getCallCount());
58    }
59   
 
60  1330 toggle private Range getMainInterval() {
61  1330 int min = 0, max = 0;
62   
63  1330 for (Range interval : ranges) {
64  1461 min += interval.getMinimum();
65  1461 if (interval.hasOpenCount() || max == Integer.MAX_VALUE) {
66  139 max = Integer.MAX_VALUE;
67    } else {
68  1322 max += interval.getMaximum();
69    }
70    }
71   
72  1330 return new Range(min, max);
73    }
74   
 
75  1330 toggle public int getCallCount() {
76  1330 return callCount;
77    }
78    }