MCPcopy Create free account
hub / github.com/apple/foundationdb / testPathFunction

Function testPathFunction

flow/Platform.actor.cpp:4032–4055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4030#endif
4031
4032int 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
4057int testPathFunction2(const char* name,
4058 std::function<std::string(std::string, bool, bool)> fun,

Callers 1

Platform.actor.cppFile · 0.70

Calls 8

printfFunction · 0.85
formatFunction · 0.70
getMethod · 0.65
isErrorMethod · 0.45
codeMethod · 0.45
getErrorMethod · 0.45
c_strMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected