2626#include " absl/container/flat_hash_map.h"
2727#include " absl/memory/memory.h"
2828#include " absl/status/statusor.h"
29+ #include " common/value.h"
2930#include " compiler/compiler.h"
3031#include " eval/public/cel_expression.h"
3132#include " runtime/activation.h"
@@ -42,6 +43,10 @@ class CelTestContext {
4243 using CelActivationFactoryFn = std::function<absl::StatusOr<cel::Activation>(
4344 const cel::expr::conformance::test::TestCase& test_case,
4445 google::protobuf::Arena* arena)>;
46+ using AssertFn = std::function<void (
47+ const cel::Value& computed,
48+ const cel::expr::conformance::test::TestCase& test_case,
49+ google::protobuf::Arena* arena)>;
4550
4651 // Creates a CelTestContext using a `CelExpressionBuilder`.
4752 //
@@ -127,6 +132,12 @@ class CelTestContext {
127132 return activation_factory_;
128133 }
129134
135+ // Allows the runner to inject a custom assertion function. If not set, the
136+ // default assertion logic in TestRunner will be used.
137+ void SetAssertFn (AssertFn assert_fn) { assert_fn_ = std::move (assert_fn); }
138+
139+ const AssertFn& assert_fn () const { return assert_fn_; }
140+
130141 private:
131142 // Delete copy and move constructors.
132143 CelTestContext (const CelTestContext&) = delete ;
@@ -173,6 +184,7 @@ class CelTestContext {
173184 std::unique_ptr<const cel::Runtime> runtime_;
174185
175186 CelActivationFactoryFn activation_factory_;
187+ AssertFn assert_fn_;
176188};
177189
178190} // namespace cel::test
0 commit comments