From 362bf7f534beebfb5bf7b0281da052ca2abfe34e Mon Sep 17 00:00:00 2001 From: Jan Ciolek Date: Wed, 18 Jan 2023 04:55:34 +0100 Subject: [PATCH] expr_test_utils: add make_float_* and make_double_* Add utilities to create float and double values in tests. Signed-off-by: Jan Ciolek --- test/lib/expr_test_utils.cc | 16 ++++++++++++++++ test/lib/expr_test_utils.hh | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/test/lib/expr_test_utils.cc b/test/lib/expr_test_utils.cc index d7cfae49be..a682fccdb6 100644 --- a/test/lib/expr_test_utils.cc +++ b/test/lib/expr_test_utils.cc @@ -46,6 +46,14 @@ raw_value make_text_raw(const sstring_view& text) { return raw_value::make_value(utf8_type->decompose(text)); } +raw_value make_float_raw(float val) { + return make_raw(val); +} + +raw_value make_double_raw(double val) { + return make_raw(val); +} + template constant make_const(T t) { data_type val_type = data_type_for(); @@ -80,6 +88,14 @@ constant make_text_const(const sstring_view& text) { return constant(make_text_raw(text), utf8_type); } +constant make_float_const(float val) { + return make_const(val); +} + +constant make_double_const(double val) { + return make_const(val); +} + // This function implements custom serialization of collection values. // Some tests require the collection to contain an empty value, // which is impossible to express using the existing code. diff --git a/test/lib/expr_test_utils.hh b/test/lib/expr_test_utils.hh index d69fc065cb..007fec1fd5 100644 --- a/test/lib/expr_test_utils.hh +++ b/test/lib/expr_test_utils.hh @@ -30,6 +30,8 @@ raw_value make_smallint_raw(int16_t val); raw_value make_int_raw(int32_t val); raw_value make_bigint_raw(int64_t val); raw_value make_text_raw(const sstring_view& text); +raw_value make_float_raw(float val); +raw_value make_double_raw(double val); constant make_empty_const(data_type type); constant make_bool_const(bool val); @@ -38,6 +40,8 @@ constant make_smallint_const(int16_t val); constant make_int_const(int32_t val); constant make_bigint_const(int64_t val); constant make_text_const(const sstring_view& text); +constant make_float_const(float val); +constant make_double_const(double val); // This function implements custom serialization of collection values. // Some tests require the collection to contain unset_value or an empty value,