| 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 |
no test coverage detected