1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <assert.h>
#include "eckit/testing/Test.h"
#include "metkit/mars/MarsLanguage.h"
namespace metkit::mars::test {
CASE("retrieve_best_match_param_matching") {
const auto language = MarsLanguage("retrieve");
// Strict is defaulted to true and this is not matching
auto match = language.bestMatch("parameter", {"parameter"}, false, false, false, {});
EXPECT(match == "parameter");
};
CASE("retrieve_best_match_param_not_matching") {
const auto language = MarsLanguage("retrieve");
// Strict is defaulted to true and this is not matching
auto match = language.bestMatch("param", {"parameter"}, false, false, false, {});
// TODO:(TKR) THIS IS MENTAL
EXPECT(match == "parameter");
auto empty = language.bestMatch("param", {"car"}, false, false, false, {});
EXPECT(empty == "");
};
CASE("retrieve_best_match_param_not_matching_throw") {
const auto language = MarsLanguage("retrieve");
// Strict is defaulted to true and this is not matching
auto match = language.bestMatch("param", {"parameter"}, true, false, false, {});
// TODO:(TKR) THIS IS MENTAL
EXPECT(match == "parameter");
EXPECT_THROWS(language.bestMatch("param", {"car"}, true, false, false, {}));
};
CASE("retrieve_best_match_param_not_matching") {
const auto language = MarsLanguage("retrieve");
// Strict is defaulted to true and this is not matching
auto match = language.bestMatch("param", {"parameter"}, false, false, true, {});
// TODO:(TKR) THIS IS MENTAL
EXPECT(match == "parameter");
match = language.bestMatch("par", {"parameter"}, false, false, true, {});
// TODO:(TKR) THIS IS MENTAL
EXPECT(match == "parameter");
match = language.bestMatch("par", {"car"}, false, false, true, {});
EXPECT(match == "");
};
} // namespace metkit::mars::test
int main(int argc, char** argv) {
putenv("METKIT_LANGUAGE_STRICT_MODE=0");
auto res = eckit::testing::run_tests(argc, argv);
unsetenv("METKIT_LANGUAGE_STRICT_MODE");
return res;
}
|