5#include "testing/testing.h"
14TEST(field, ConstantFunction)
39 auto index_func = [](
int i) {
return i; };
46 GField index_field{std::make_shared<IndexFieldInput>()};
75TEST(field, VArrayInputMultipleOutputs)
77 std::shared_ptr<FieldInput> index_input = std::make_shared<IndexFieldInput>();
78 GField field_1{index_input};
79 GField field_2{index_input};
105 GField index_field{std::make_shared<IndexFieldInput>()};
107 auto add_fn = mf::build::SI2_SO<int, int, int>(
"add", [](
int a,
int b) {
return a +
b; });
128 GField index_field{std::make_shared<IndexFieldInput>()};
130 auto add_fn = mf::build::SI2_SO<int, int, int>(
"add", [](
int a,
int b) {
return a +
b; });
133 auto add_10_fn = mf::build::SI1_SO<int, int>(
"add_10", [](
int a) {
return a + 10; });
154 mf::Signature signature_;
159 mf::SignatureBuilder builder{
"Two Outputs", signature_};
160 builder.single_input<
int>(
"In1");
161 builder.single_input<
int>(
"In2");
162 builder.single_output<
int>(
"Add");
163 builder.single_output<
int>(
"Add10");
175 add_10[
i] =
add[
i] + 10;
183 GField index_field_1{std::make_shared<IndexFieldInput>()};
184 GField index_field_2{std::make_shared<IndexFieldInput>()};
187 {index_field_1, index_field_2});
214TEST(field, TwoFunctionsTwoOutputs)
216 GField index_field{std::make_shared<IndexFieldInput>()};
219 {index_field, index_field});
228 auto add_10_fn = mf::build::SI1_SO<int, int>(
"add_10", [](
int a) {
return a + 10; });
235 field_evaluator.
add(result_field_1, &result_1);
236 field_evaluator.
add(result_field_2, &result_2);
257 scope, {constant_field, constant_field},
mask, field_context);
270 static mf::tests::OptionalOutputsFunction
fn;
276 field_evaluator.
add(field, &results);
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MutableSpan< T > as_mutable_span()
static IndexMask from_indices(Span< T > indices, IndexMaskMemory &memory)
T get(const int64_t index) const
static VArray from_func(const int64_t size, GetFunc get_func)
int add(GField field, GVArray *varray_ptr)
int add_with_destination(GField field, GVMutableArray dst)
static std::shared_ptr< FieldOperation > from(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
void set_signature(const Signature *signature)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
TEST(field, ConstantFunction)
Vector< GVArray > evaluate_fields(ResourceScope &scope, Span< GFieldRef > fields_to_evaluate, const IndexMask &mask, const FieldContext &context, Span< GVMutableArray > dst_varrays={})