Helper method to test string startsWith() function
| 41 | |
| 42 | // Helper method to test string startsWith() function |
| 43 | void TestStringInclusion(absl::string_view func_name, |
| 44 | const std::vector<bool>& call_style, |
| 45 | const std::string& test_string, |
| 46 | const std::string& included, bool result) { |
| 47 | std::vector<bool> call_styles = {true, false}; |
| 48 | |
| 49 | for (auto call_style : call_styles) { |
| 50 | auto functions = registry_.FindOverloads( |
| 51 | func_name, call_style, |
| 52 | {CelValue::Type::kString, CelValue::Type::kString}); |
| 53 | ASSERT_EQ(functions.size(), 1); |
| 54 | |
| 55 | auto func = functions[0]; |
| 56 | |
| 57 | std::vector<CelValue> args = {CelValue::CreateString(&test_string), |
| 58 | CelValue::CreateString(&included)}; |
| 59 | CelValue result_value = CelValue::CreateNull(); |
| 60 | google::protobuf::Arena arena; |
| 61 | absl::Span<CelValue> arg_span(&args[0], args.size()); |
| 62 | auto status = func->Evaluate(arg_span, &result_value, &arena); |
| 63 | |
| 64 | ASSERT_OK(status); |
| 65 | ASSERT_TRUE(result_value.IsBool()); |
| 66 | ASSERT_EQ(result_value.BoolOrDie(), result); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void TestStringStartsWith(const std::string& test_string, |
| 71 | const std::string& prefix, bool result) { |
nothing calls this directly
no test coverage detected