| 4030 | #endif |
| 4031 | |
| 4032 | int testPathFunction(const char* name, |
| 4033 | std::function<std::string(std::string)> fun, |
| 4034 | std::string a, |
| 4035 | ErrorOr<std::string> b) { |
| 4036 | ErrorOr<std::string> result; |
| 4037 | try { |
| 4038 | result = fun(a); |
| 4039 | } catch (Error& e) { |
| 4040 | result = e; |
| 4041 | } |
| 4042 | bool r = result.isError() == b.isError() && (b.isError() || b.get() == result.get()) && |
| 4043 | (!b.isError() || b.getError().code() == result.getError().code()); |
| 4044 | |
| 4045 | printf("%s: %s('%s') -> %s", |
| 4046 | r ? "PASS" : "FAIL", |
| 4047 | name, |
| 4048 | a.c_str(), |
| 4049 | result.isError() ? result.getError().what() : format("'%s'", result.get().c_str()).c_str()); |
| 4050 | if (!r) { |
| 4051 | printf(" *ERROR* expected %s", b.isError() ? b.getError().what() : format("'%s'", b.get().c_str()).c_str()); |
| 4052 | } |
| 4053 | printf("\n"); |
| 4054 | return r ? 0 : 1; |
| 4055 | } |
| 4056 | |
| 4057 | int testPathFunction2(const char* name, |
| 4058 | std::function<std::string(std::string, bool, bool)> fun, |