3 #include "testing/testing.h"
45 const char *
names[1] = {
"x"};
85 #define TEST_PARSE_FAIL(name, str) \
86 TEST(expr_pylike, ParseFail_##name) \
88 expr_pylike_parse_fail_test(str); \
116 #define TEST_CONST(name, str, value) \
117 TEST(expr_pylike, Const_##name) \
119 expr_pylike_const_test(str, value, true); \
123 #define TEST_RESULT(name, str, value) \
124 TEST(expr_pylike, Result_##name) \
126 expr_pylike_const_test(str, value, false); \
130 #define TEST_EVAL(name, str, x, value) \
131 TEST(expr_pylike, Eval_##name) \
133 expr_pylike_eval_test(str, x, value); \
276 TEST(expr_pylike, Eval_Ternary1)
281 for (
int i = 0; i <= 10; i++) {
283 double v = (
x < 4) ? (
x / 2) : (
x < 8) ? (
x - 2) : (
x * 2 - 12);
291 TEST(expr_pylike, MultipleArgs)
293 const char *
names[3] = {
"x",
"y",
"x"};
294 double values[3] = {1.0, 2.0, 3.0};
311 const char *
names[3] = {
"x",
"y",
"z"};
322 #define TEST_ERROR(name, str, x, code) \
323 TEST(expr_pylike, Error_##name) \
325 expr_pylike_error_test(str, x, code); \
355 TEST(expr_pylike, Error_ArgumentCount)
@ EXPR_PYLIKE_FATAL_ERROR
@ EXPR_PYLIKE_DIV_BY_ZERO
eExprPyLike_EvalStatus BLI_expr_pylike_eval(struct ExprPyLike_Parsed *expr, const double *param_values, int param_values_len, double *r_result)
ExprPyLike_Parsed * BLI_expr_pylike_parse(const char *expression, const char **param_names, int param_names_len)
bool BLI_expr_pylike_is_using_param(struct ExprPyLike_Parsed *expr, int index)
bool BLI_expr_pylike_is_valid(struct ExprPyLike_Parsed *expr)
bool BLI_expr_pylike_is_constant(struct ExprPyLike_Parsed *expr)
#define TEST_RESULT(name, str, value)
EXPR_PYLIKE_DIV_BY_ZERO Error_Invalid
#define TEST_EVAL(name, str, x, value)
#define TEST_CONST(name, str, value)
#define TEST_PARSE_FAIL(name, str)
static ExprPyLike_Parsed * parse_for_eval(const char *str, bool nonconst)
static void verify_eval_result(ExprPyLike_Parsed *expr, double x, double value)
static void expr_pylike_const_test(const char *str, double value, bool force_const)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
static void expr_pylike_eval_test(const char *str, double x, double value)
static void expr_pylike_error_test(const char *str, double x, eExprPyLike_EvalStatus error)
static void expr_pylike_parse_fail_test(const char *str)
BLI_expr_pylike_free(expr)
TEST(expr_pylike, Eval_Ternary1)
#define TEST_ERROR(name, str, x, code)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
MINLINE float smoothstep(float edge0, float edge1, float x)
ccl_device_inline float3 pow(float3 v, float e)
ccl_device_inline float3 log(float3 v)
static void error(const char *str)
static float lerp(float t, float a, float b)
T clamp(const T &a, const T &min, const T &max)