MCPcopy Create free account
hub / github.com/Gecode/gecode / check

Function check

test/ldsb.cpp:101–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 */
100 template <class T, class VarArgsType>
101 bool
102 check(DFS<T>& e, std::vector<VarArgsType> expected) {
103 int nexpected = expected.size();
104 for (int i = 0 ; i < nexpected ; ++i) {
105 T* s = e.next();
106 if (s == nullptr) {
107 if (opt.log) {
108 olog << "Expected a solution but there are no more solutions." << std::endl;
109 olog << "(Expected " << nexpected << " but only found " << i << ")" << std::endl;
110 olog << "Expected: " << expected[i] << std::endl;
111 }
112 return false;
113 }
114 if (!equal(s->solution(), expected[i])) {
115 if (opt.log) {
116 olog << "Solution does not match expected." << std::endl;
117 olog << "Solution: " << s->solution() << std::endl;
118 olog << "Expected: " << expected[i] << std::endl;
119 }
120 return false;
121 }
122 delete s;
123 }
124 T* s = e.next();
125 if (s != nullptr) {
126 if (opt.log) {
127 olog << "More solutions than expected:" << std::endl;
128 olog << "(Expected only " << nexpected << ")" << std::endl;
129 olog << s->solution() << std::endl;
130 }
131 return false;
132 }
133
134 // Nothing went wrong.
135 return true;
136 }
137
138
139 /// %Test space

Callers 15

runMethod · 0.70
runMethod · 0.70
runMethod · 0.70
fillMethod · 0.50
LinIntExprMethod · 0.50
fillMethod · 0.50
LinFloatExprMethod · 0.50
atmostOneFunction · 0.50
relFunction · 0.50
cardinalityFunction · 0.50
relFunction · 0.50
relFunction · 0.50

Calls 4

equalFunction · 0.70
sizeMethod · 0.45
nextMethod · 0.45
solutionMethod · 0.45

Tested by

no test coverage detected