mirror of https://github.com/ecmwf/eccodes.git
codes_get_codetable_contents_malloc: Renamed and added test
This commit is contained in:
parent
fe2ae5c151
commit
dca34cfc2d
|
@ -340,7 +340,7 @@ void grib_smart_table_delete(grib_context* c);
|
||||||
|
|
||||||
/* grib_accessor_class_codetable.cc*/
|
/* grib_accessor_class_codetable.cc*/
|
||||||
void grib_codetable_delete(grib_context* c);
|
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*/
|
/* grib_accessor_class_codetable_units.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;
|
long lvalue = 0;
|
||||||
size_t size = 1;
|
size_t size = 1;
|
||||||
|
|
|
@ -50,6 +50,7 @@ list(APPEND test_c_bins
|
||||||
codes_set_samples_path
|
codes_set_samples_path
|
||||||
codes_compare_keys
|
codes_compare_keys
|
||||||
codes_dump_content
|
codes_dump_content
|
||||||
|
codes_codetable
|
||||||
grib_sh_ieee64
|
grib_sh_ieee64
|
||||||
grib_ieee
|
grib_ieee
|
||||||
grib_set_bytes
|
grib_set_bytes
|
||||||
|
@ -243,6 +244,7 @@ if( HAVE_BUILD_TOOLS )
|
||||||
grib_set_force
|
grib_set_force
|
||||||
bufr_ecc-556
|
bufr_ecc-556
|
||||||
codes_ecc-1698
|
codes_ecc-1698
|
||||||
|
codes_codetable
|
||||||
gts_get
|
gts_get
|
||||||
gts_ls
|
gts_ls
|
||||||
gts_count
|
gts_count
|
||||||
|
|
|
@ -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 <stdio.h>
|
||||||
|
#include "grib_api_internal.h"
|
||||||
|
|
||||||
|
#undef NDEBUG
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
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<num_entries;++i) {
|
||||||
|
printf(" i=%zu |%s| |%s|\n", i, entries[i].abbreviation, entries[i].title);
|
||||||
|
}
|
||||||
|
free(entries);
|
||||||
|
grib_handle_delete(h);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
REDIRECT=/dev/null
|
||||||
|
|
||||||
|
label="codes_codetable_test"
|
||||||
|
tempGrib=temp.$label.grib
|
||||||
|
tempLog=temp.$label.log
|
||||||
|
|
||||||
|
$EXEC ${test_dir}/codes_codetable
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -f $tempGrib $tempLog
|
Loading…
Reference in New Issue