diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 26a6d0851..a68f0f343 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -340,7 +340,7 @@ void grib_smart_table_delete(grib_context* c); /* grib_accessor_class_codetable.cc*/ void grib_codetable_delete(grib_context* c); -int codes_get_all_codetable_entries_malloc(const grib_handle* h, const char* key, code_table_entry** entries, size_t* num_entries); +int codes_get_codetable_contents_malloc(const grib_handle* h, const char* key, code_table_entry** entries, size_t* num_entries); /* grib_accessor_class_codetable_units.cc*/ diff --git a/src/grib_accessor_class_codetable.cc b/src/grib_accessor_class_codetable.cc index 6ecafa05a..cccb573dd 100644 --- a/src/grib_accessor_class_codetable.cc +++ b/src/grib_accessor_class_codetable.cc @@ -523,7 +523,7 @@ void grib_codetable_delete(grib_context* c) } } -int codes_get_all_codetable_entries_malloc(const grib_handle* h, const char* key, code_table_entry** entries, size_t* num_entries) +int codes_get_codetable_contents_malloc(const grib_handle* h, const char* key, code_table_entry** entries, size_t* num_entries) { long lvalue = 0; size_t size = 1; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 55818b054..8079b9082 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -50,6 +50,7 @@ list(APPEND test_c_bins codes_set_samples_path codes_compare_keys codes_dump_content + codes_codetable grib_sh_ieee64 grib_ieee grib_set_bytes @@ -243,6 +244,7 @@ if( HAVE_BUILD_TOOLS ) grib_set_force bufr_ecc-556 codes_ecc-1698 + codes_codetable gts_get gts_ls gts_count diff --git a/tests/codes_codetable.cc b/tests/codes_codetable.cc new file mode 100644 index 000000000..36b36f98a --- /dev/null +++ b/tests/codes_codetable.cc @@ -0,0 +1,35 @@ +/* + * (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 +#include "grib_api_internal.h" + +#undef NDEBUG +#include + +int main(int argc, char* argv[]) +{ + Assert(argc == 1); + grib_handle* h = grib_handle_new_from_samples(0, "GRIB2"); + + code_table_entry* entries = NULL; + size_t num_entries = 0; + const char* keyname = "indicatorOfUnitOfTimeRange"; + int err = codes_get_codetable_contents_malloc(h, keyname, &entries, &num_entries); + Assert(!err); + Assert(num_entries == 13); + + for (size_t i=0; i