MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / TEST

Function TEST

extensions/formatting_test.cc:99–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99TEST(StringFormatLimitsTest, MaxPrecisionOption) {
100 google::protobuf::Arena arena;
101 const RuntimeOptions options;
102 StringsExtensionFormatOptions format_options;
103 format_options.max_precision = 99;
104 ASSERT_OK_AND_ASSIGN(auto builder,
105 CreateStandardRuntimeBuilder(
106 internal::GetTestingDescriptorPool(), options));
107 ASSERT_THAT(RegisterStringFormattingFunctions(builder.function_registry(),
108 options, format_options),
109 IsOk());
110
111 ASSERT_OK_AND_ASSIGN(auto runtime, std::move(builder).Build());
112
113 ASSERT_OK_AND_ASSIGN(ParsedExpr expr, Parse("'%.100f'.format([1.123])",
114 "<input>", ParserOptions{}));
115 ASSERT_OK_AND_ASSIGN(std::unique_ptr<Program> program,
116 ProtobufRuntimeAdapter::CreateProgram(*runtime, expr));
117 Activation activation;
118
119 ASSERT_OK_AND_ASSIGN(Value value, program->Evaluate(&arena, activation));
120 ASSERT_TRUE(value.Is<ErrorValue>());
121 EXPECT_THAT(value.GetError().ToStatus().message(),
122 HasSubstr("precision specifier exceeds maximum of 99"));
123}
124
125INSTANTIATE_TEST_SUITE_P(StringFormatLimitsTest, StringFormatLimitsTest,
126 ValuesIn<std::string>({

Callers

nothing calls this directly

Calls 6

CreateProgramFunction · 0.85
messageMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
ToStatusMethod · 0.45
GetErrorMethod · 0.45

Tested by

no test coverage detected