|
| 1 | +#include <cstdio> |
1 | 2 | #include <cstdlib> |
2 | 3 | #include <iomanip> |
3 | 4 | #include <iostream> |
| 5 | +#include <sstream> |
4 | 6 | #include <string> |
5 | 7 | #include "gecko.h" |
6 | 8 | #include "gecko/graph.h" |
7 | 9 |
|
8 | 10 | using namespace Gecko; |
9 | 11 |
|
| 12 | +template <typename T> |
| 13 | +static std::string |
| 14 | +stringize(T val) |
| 15 | +{ |
| 16 | + std::ostringstream s; |
| 17 | + s << val; |
| 18 | + return s.str(); |
| 19 | +} |
| 20 | + |
10 | 21 | // print library version info |
11 | 22 | static bool |
12 | 23 | init() |
@@ -66,7 +77,7 @@ path_test( |
66 | 77 | Node::Index i = graph.permutation(rank + 0); |
67 | 78 | Node::Index j = graph.permutation(rank + 1); |
68 | 79 | if (!graph.arc_index(i, j)) |
69 | | - return std::string("{") + std::to_string(i) + std::string(", ") + std::to_string(j) + std::string("} is not an edge"); |
| 80 | + return std::string("{") + stringize(i) + std::string(", ") + stringize(j) + std::string("} is not an edge"); |
70 | 81 | } |
71 | 82 |
|
72 | 83 | return std::string(); |
@@ -111,7 +122,7 @@ hypercube_test( |
111 | 122 | Node::Index i = graph.permutation(rank + 0); |
112 | 123 | Node::Index j = graph.permutation(rank + 1); |
113 | 124 | if (!graph.arc_index(i, j)) |
114 | | - return std::string("{") + std::to_string(i) + std::string(", ") + std::to_string(j) + std::string("} is not an edge"); |
| 125 | + return std::string("{") + stringize(i) + std::string(", ") + stringize(j) + std::string("} is not an edge"); |
115 | 126 | } |
116 | 127 |
|
117 | 128 | return std::string(); |
@@ -170,7 +181,7 @@ grid_test( |
170 | 181 | if (cost <= Float(1 + epsilon) * mincost) |
171 | 182 | return std::string(); |
172 | 183 | else |
173 | | - return std::to_string(cost) + " > " + std::to_string(mincost); |
| 184 | + return stringize(cost) + " > " + stringize(mincost); |
174 | 185 | } |
175 | 186 |
|
176 | 187 | // report the result of a test and return 1 if it failed |
@@ -224,14 +235,14 @@ int main(int argc, char* argv[]) |
224 | 235 | // order hypercubes |
225 | 236 | for (uint dims = 1; dims <= maxdims; dims++) { |
226 | 237 | std::string error = hypercube_test(dims); |
227 | | - failures += report(std::string("hypercube test #") + std::to_string(dims), error); |
| 238 | + failures += report(std::string("hypercube test #") + stringize(dims), error); |
228 | 239 | tests++; |
229 | 240 | } |
230 | 241 |
|
231 | 242 | // order grids |
232 | 243 | for (uint size = 1; size <= maxsize; size++) { |
233 | 244 | std::string error = grid_test(size); |
234 | | - failures += report(std::string("grid test #") + std::to_string(size), error); |
| 245 | + failures += report(std::string("grid test #") + stringize(size), error); |
235 | 246 | tests++; |
236 | 247 | } |
237 | 248 |
|
|
0 commit comments