Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CheckGraph |
|
| 1.2;1,2 |
1 | /* | |
2 | This file is part of Combean. | |
3 | ||
4 | Combean is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation; either version 2 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | Combean is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with Combean; if not, write to the Free Software | |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | /* | |
19 | * Created on 11.01.2005 | |
20 | * | |
21 | */ | |
22 | package net.sourceforge.combean.test.helpers.checks; | |
23 | ||
24 | import java.util.Iterator; | |
25 | ||
26 | import junit.framework.Assert; | |
27 | import net.sourceforge.combean.graph.iterators.EdgeIteratorAsIterator; | |
28 | import net.sourceforge.combean.graph.iterators.NodeIteratorAsIterator; | |
29 | import net.sourceforge.combean.interfaces.graph.EdgeIterator; | |
30 | import net.sourceforge.combean.interfaces.graph.NodeIterator; | |
31 | import net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleEdgeMap; | |
32 | import net.sourceforge.combean.interfaces.graph.prop.GlobalNumberedEdgesGraphProp; | |
33 | ||
34 | /** | |
35 | * @author schickin | |
36 | * | |
37 | */ | |
38 | 0 | public class CheckGraph { |
39 | ||
40 | /** | |
41 | * Check a NodeIterator for termination after a given number of iterations | |
42 | * @see Check#checkNumIterations(Iterator, long) | |
43 | * | |
44 | * @param it the iterator | |
45 | * @param numIterations the expected number of iterations. | |
46 | */ | |
47 | public static final void checkNumIterations(NodeIterator it, long numIterations) { | |
48 | 27 | Check.checkNumIterations(new NodeIteratorAsIterator(it), numIterations); |
49 | 27 | } |
50 | ||
51 | /** | |
52 | * Check an EdgeIterator for termination after a given number of iterations | |
53 | * @see Check#checkNumIterations(Iterator, long) | |
54 | * | |
55 | * @param it the iterator | |
56 | * @param numIterations the expected number of iterations. | |
57 | */ | |
58 | public static final void checkNumIterations(EdgeIterator it, long numIterations) { | |
59 | 120 | Check.checkNumIterations(new EdgeIteratorAsIterator(it), numIterations); |
60 | 120 | } |
61 | ||
62 | /** | |
63 | * @see Check#checkIdenticalIterations(Iterator, Iterator) | |
64 | * | |
65 | * @param itOne | |
66 | * @param itTwo | |
67 | */ | |
68 | public static final void checkIdenticalIterations( | |
69 | NodeIterator itOne, NodeIterator itTwo) { | |
70 | 3 | Check.checkIdenticalIterations(new NodeIteratorAsIterator(itOne), |
71 | new NodeIteratorAsIterator(itTwo)); | |
72 | 3 | } |
73 | ||
74 | /** | |
75 | * @see Check#checkIdenticalIterations(Iterator, Iterator) | |
76 | * @param itOne | |
77 | * @param itTwo | |
78 | */ | |
79 | public static final void checkIdenticalIterations( | |
80 | EdgeIterator itOne, EdgeIterator itTwo) { | |
81 | 0 | Check.checkIdenticalIterations(new EdgeIteratorAsIterator(itOne), |
82 | new EdgeIteratorAsIterator(itTwo)); | |
83 | 0 | } |
84 | ||
85 | public static final void checkDoubleEdgeMap(GlobalNumberedEdgesGraphProp g, | |
86 | FixedDoubleEdgeMap edgeMap, | |
87 | double[] predefinedValues, double tolerance) { | |
88 | 12 | Assert.assertEquals(predefinedValues.length, g.getNumEdges()); |
89 | 72 | for (int i = 0; i < g.getNumEdges(); i++) { |
90 | 60 | Assert.assertEquals("edge #" + i + " must have predefined value", |
91 | predefinedValues[i], | |
92 | edgeMap.getDouble(g.getEdge(i)), | |
93 | tolerance); | |
94 | } | |
95 | 12 | } |
96 | } |