2015-11-12 01:42:49 +08:00
|
|
|
/* This is part of the netCDF package.
|
2018-12-07 06:27:32 +08:00
|
|
|
Copyright 2018 University Corporation for Atmospheric Research/Unidata.
|
2015-11-12 01:42:49 +08:00
|
|
|
See COPYRIGHT file for conditions of use.
|
|
|
|
|
|
|
|
This test was provided by Jeff Whitaker as an example of a bug,
|
|
|
|
specifically a segfault when re-writing an NC_CHAR attribute as
|
|
|
|
an NC_STRING attribute.
|
|
|
|
|
|
|
|
See https://github.com/Unidata/netcdf-c/issues/149
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2019-01-02 20:37:54 +08:00
|
|
|
#include <netcdf.h>
|
2015-11-12 01:42:49 +08:00
|
|
|
#include <nc_tests.h>
|
2016-10-22 03:24:40 +08:00
|
|
|
#include "err_macros.h"
|
2015-11-12 01:42:49 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define FILE_NAME "tst_atts_string_rewrite.nc"
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int dataset_id;
|
|
|
|
const char *attstring[1] = {"bar"};
|
|
|
|
int res = 0;
|
|
|
|
printf("\n*** Testing overwriting text attribute with string attribute.\n");
|
|
|
|
printf("\n***Creating file...");
|
|
|
|
|
|
|
|
res = nc_create(FILE_NAME, NC_NETCDF4, &dataset_id); if(res) ERR;
|
|
|
|
printf("Success\n");
|
|
|
|
|
|
|
|
printf("Creating global attribute with nc_put_att_text...");
|
|
|
|
res = nc_put_att_text(dataset_id, NC_GLOBAL, "foo", 3, "bar");
|
2018-03-16 22:38:40 +08:00
|
|
|
printf("Success\n");
|
2015-11-12 01:42:49 +08:00
|
|
|
|
|
|
|
printf("Overwriting global attribute with nc_put_att_string...");
|
|
|
|
res = nc_put_att_string(dataset_id, NC_GLOBAL, "foo", 1, attstring);
|
|
|
|
printf("Success\n");
|
|
|
|
|
|
|
|
printf("Closing file...");
|
|
|
|
res = nc_close(dataset_id);
|
|
|
|
printf("Success\n");
|
|
|
|
|
|
|
|
printf("Test Finished.\n");
|
|
|
|
SUMMARIZE_ERR;
|
|
|
|
FINAL_RESULTS;
|
|
|
|
|
|
|
|
}
|