From ea84ba63810c5f69d150725dbd31ef62d9e7d13e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 10 Jan 2024 14:43:23 +0000 Subject: [PATCH] Testing: is_in_list expression --- src/grib_expression_class_is_in_list.cc | 25 +++++++------- tests/CMakeLists.txt | 1 + tests/filter_is_in_list.sh | 45 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 12 deletions(-) create mode 100755 tests/filter_is_in_list.sh diff --git a/src/grib_expression_class_is_in_list.cc b/src/grib_expression_class_is_in_list.cc index 4a6c3dc3b..0d61cf82c 100644 --- a/src/grib_expression_class_is_in_list.cc +++ b/src/grib_expression_class_is_in_list.cc @@ -173,22 +173,23 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) static int evaluate_double(grib_expression* g, grib_handle* h, double* result) { - grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; + return GRIB_NOT_IMPLEMENTED; + // grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; + // int err = 0; + // char mybuf[1024] = {0,}; + // size_t size = 1024; - grib_trie* list = load_list(h->context, g, &err); + // grib_trie* list = load_list(h->context, g, &err); - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; + // if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) + // return err; - if (grib_trie_get(list, mybuf)) - *result = 1; - else - *result = 0; + // if (grib_trie_get(list, mybuf)) + // *result = 1; + // else + // *result = 0; - return err; + // return err; } static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3bed4fc84..9c50bad59 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,6 +97,7 @@ if( HAVE_BUILD_TOOLS ) grib_ifsParam grib_packing_order filter_substr + filter_is_in_list filter_transient_darray grib_uerra grib_ecpoint diff --git a/tests/filter_is_in_list.sh b/tests/filter_is_in_list.sh new file mode 100755 index 000000000..4f771a43b --- /dev/null +++ b/tests/filter_is_in_list.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="filter_is_in_list_test" +temp=temp.$label.txt +sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +# Evaluate long +${tools_dir}/grib_filter - $sample <$temp <