EasyMock 2.3

Clover coverage report - EasyMock 2.3
Coverage timestamp: mar. juil. 10 2007 02:46:04 CEST
FRAMES NO FRAMES

file stats: | LOC: | 75 |  | Methods: | 6
| NCLOC: | 58 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

Results.java

100%

100%

100%

100%

1 |  | /*
2 |  | * Copyright (c) 2001-2007 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.util.ArrayList;
8 |  | import java.util.LinkedList;
9 |  | import java.util.List;
10 |  |
11 |  | public class Results {
12 |  |
13 |  | private int callCount;
14 |  |
15 |  | private LinkedList<Range> ranges = new LinkedList<Range>();
16 |  |
17 |  | private List<Result> results = new ArrayList<Result>();
18 |  |
19 | 401 | public void add(Result result, Range range) {
20 | 401 | if (!ranges.isEmpty()) {
21 | 39 | Range lastRange = ranges.getLast();
22 | 39 | if (!lastRange.hasFixedCount())
23 | 2 | throw new RuntimeExceptionWrapper(
24 |  | new IllegalStateException(
25 |  | "last method called on mock already has a non-fixed count set."));
26 |  | }
27 | 399 | ranges.add(range);
28 | 399 | results.add(result);
29 |  | }
30 |  |
31 | 447 | public Result next() {
32 | 447 | int currentPosition = 0;
33 | 447 | for (int i = 0; i < ranges.size(); i++) {
34 | 529 | Range interval = ranges.get(i);
35 | 529 | if (interval.hasOpenCount()) {
36 | 52 | callCount += 1;
37 | 52 | return results.get(i);
38 |  | }
39 | 477 | currentPosition += interval.getMaximum();
40 | 477 | if (currentPosition > callCount) {
41 | 360 | callCount += 1;
42 | 360 | return results.get(i);
43 |  | }
44 |  | }
45 | 35 | return null;
46 |  | }
47 |  |
48 | 993 | public boolean hasValidCallCount() {
49 | 993 | return getMainInterval().contains(getCallCount());
50 |  | }
51 |  |
52 | 224 | @Override
53 |  | public String toString() {
54 | 224 | return getMainInterval().expectedAndActual(getCallCount());
55 |  | }
56 |  |
57 | 1217 | private Range getMainInterval() {
58 | 1217 | int min = 0, max = 0;
59 |  |
60 | 1217 | for (Range interval : ranges) {
61 | 1355 | min += interval.getMinimum();
62 | 1355 | if (interval.hasOpenCount() || max == Integer.MAX_VALUE) {
63 | 142 | max = Integer.MAX_VALUE;
64 |  | } else {
65 | 1213 | max += interval.getMaximum();
66 |  | }
67 |  | }
68 |  |
69 | 1217 | return new Range(min, max);
70 |  | }
71 |  |
72 | 1217 | public int getCallCount() {
73 | 1217 | return callCount;
74 |  | }
75 |  | }