Testing: Add test for accessor g1day_of_the_year_date

This commit is contained in:
Shahram Najm 2021-08-14 18:14:13 +01:00
parent 6132e9d8de
commit d41b90070d
3 changed files with 26 additions and 5 deletions

View File

@ -142,7 +142,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_string(dumper, a, NULL);
@ -153,7 +152,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
/* special clim case where each mont have 30 days.. to comply with mars*/
grib_accessor_g1day_of_the_year_date* self = (grib_accessor_g1day_of_the_year_date*)a;
char tmp[1024];
long year = 0;
@ -164,7 +162,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
long fullyear = 0;
long fake_day_of_year = 0;
size_t l;
grib_get_long_internal(grib_handle_of_accessor(a), self->century, &century);
@ -175,7 +172,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
if (*len < 1)
return GRIB_BUFFER_TOO_SMALL;
fullyear = ((century - 1) * 100 + year);
fake_day_of_year = ((month - 1) * 30) + day;
sprintf(tmp, "%04ld-%03ld", fullyear, fake_day_of_year);
@ -189,6 +185,5 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
*len = l;
strcpy(val, tmp);
return GRIB_SUCCESS;
}

View File

@ -105,6 +105,7 @@ if( HAVE_BUILD_TOOLS )
grib_grid_lambert_conformal
grib_grid_polar_stereographic
grib_g1monthlydate
grib_g1day_of_the_year_date
grib_g1fcperiod)
# These tests do require data downloads

View File

@ -0,0 +1,25 @@
#!/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.sh
label="grib_g1day_of_the_year_date"
sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
temp=temp.$label.grib
${tools_dir}/grib_set -s marsType=s3,marsStream=mpic $sample_g1 $temp
grib_check_key_equals $temp "mars.date:s,dayOfTheYearDate:s" "2006-076 2006-076"
${tools_dir}/grib_set -s marsType=s3,marsStream=ukmo $sample_g1 $temp
grib_check_key_equals $temp "mars.date:s,dayOfTheYearDate:s" "2006-076 2006-076"
# Clean up
rm -f $temp