<commit_before>/* This is part of the netCDF package.
   Copyright 2005 University Corporation for Atmospheric Research/Unidata
   See COPYRIGHT file for conditions of use.

   Test even more data conversions.

   $Id: tst_converts2.c,v 1.14 2010/06/01 15:34:51 ed Exp $
*/

#include <nc_tests.h>
#include "netcdf.h"
#include "nc4internal.h"

#define FILE_NAME "tst_converts2.nc"
#define VAR_NAME "Monkey"

int
main(int argc, char **argv)
{
   int ncid, varid;
   signed char schar_in, schar = -2;
   char var_name[NC_MAX_NAME+1];
   int ndims, natts, int_in;
   long long_in;
   nc_type var_type;
 
   printf("\n*** Testing more netcdf-4 data conversion.\n");
   printf ("*** Testing NC_BYTE conversions...");
   {
      /* Write a scalar NC_BYTE with value -2. */
      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
      if (nc_def_var(ncid, VAR_NAME, NC_BYTE, 0, NULL, &varid)) ERR;
      if (nc_put_var_schar(ncid, varid, &schar)) ERR;
      if (nc_close(ncid)) ERR;

      /* Now open the file and check it. */
      if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
      if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, NULL, &natts)) ERR;
      if (strcmp(var_name, VAR_NAME) || natts !=0 || ndims != 0 || 
	  var_type != NC_BYTE) ERR;
      if (nc_get_var_schar(ncid, varid, &schar_in)) ERR;
      if (schar_in != schar) ERR;
      if (nc_get_var_int(ncid, varid, &int_in)) ERR;
      if (int_in != schar) ERR;
      if (nc_get_var_long(ncid, varid, &long_in)) ERR;
      if (long_in != schar) ERR;
      if (nc_close(ncid)) ERR;
   }
   SUMMARIZE_ERR;
   printf ("*** Testing NC_USHORT conversions...");
   {
      /* Write a scalar NC_USHORT with value 65535, converted from various types. */
       static unsigned short usval[1] = {65535};
       int ival = 65535;
       long lval = 65535;
       float fval = 65535;
       double dval = 65535;
       int dimid;
       size_t coord[1];
       unsigned short ushort_in;
       int int_in;
       long long_in;
       float float_in;
       double double_in;
#define DIM_NAME "n"
#define DIM_LEN 5
      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
      if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
      if (nc_def_var(ncid, VAR_NAME, NC_USHORT, 1, &dimid, &varid)) ERR;
      coord[0] = 1;
      if (nc_put_var1_int(ncid, varid, &coord[0], &ival)) ERR;
      coord[0] = 2;
      if (nc_put_var1_float(ncid, varid, &coord[0], &fval)) ERR;
      coord[0] = 3;
      if (nc_put_var1_double(ncid, varid, &coord[0], &dval)) ERR; 
      /* This cause a SIGABRT error */
      /*       coord[0] = 0; */
      /*       if (nc_put_var1_ushort(ncid, varid, &coord[0], &usval[0])) ERR; */

      if (nc_close(ncid)) ERR;

      /* Now open the file and check it. */
      if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
      if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, NULL, &natts)) ERR;
      if (strcmp(var_name, VAR_NAME) || natts !=0 || ndims != 1 || 
	  var_type != NC_USHORT) ERR;
      /* These also cause SIGABRT */
      /*       coord[0] = 1; */
      /*       if (nc_get_var1_int(ncid, varid, &coord[1], &int_in)) ERR; */
      /*       if (int_in != ival) ERR; */
      /*       coord[0] = 2; */
      /*       if (nc_get_var1_float(ncid, varid, &coord[2], &float_in)) ERR; */
      /*       if (float_in != fval) ERR; */
      /*       coord[0] = 3; */
      /*       if (nc_get_var1_double(ncid, varid, &coord[3], &double_in)) ERR; */
      /*       if (double_in != dval) ERR; */
      /*       coord[0] = 4; */
      /*       if (nc_get_var1_long(ncid, varid, &coord[4], &long_in)) ERR; */
      /*       if (long_in != lval) ERR; */
      /*       coord[0] = 0; */
      /*       if (nc_get_var1_ushort(ncid, varid, &coord[0], &ushort_in)) ERR; */
      /*       if (ushort_in != usval[0]) ERR; */<commit_msg>clean up test for USHORT conversions bug fix<commit_after>/* This is part of the netCDF package.
   Copyright 2005 University Corporation for Atmospheric Research/Unidata
   See COPYRIGHT file for conditions of use.

   Test even more data conversions.

   $Id: tst_converts2.c,v 1.14 2010/06/01 15:34:51 ed Exp $
*/

#include <nc_tests.h>
#include "netcdf.h"
#include "nc4internal.h"

#define FILE_NAME "tst_converts2.nc"
#define VAR_NAME "Monkey"
#define DIM_NAME "n"
#define DIM_LEN 5

int
main(int argc, char **argv)
{
   int ncid, varid;
   signed char schar_in, schar = -2;
   char var_name[NC_MAX_NAME+1];
   int ndims, natts, int_in;
   long long_in;
   nc_type var_type;
 
   printf("\n*** Testing more netcdf-4 data conversion.\n");
   printf ("*** Testing NC_BYTE conversions...");
   {
      /* Write a scalar NC_BYTE with value -2. */
      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
      if (nc_def_var(ncid, VAR_NAME, NC_BYTE, 0, NULL, &varid)) ERR;
      if (nc_put_var_schar(ncid, varid, &schar)) ERR;
      if (nc_close(ncid)) ERR;

      /* Now open the file and check it. */
      if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
      if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, NULL, &natts)) ERR;
      if (strcmp(var_name, VAR_NAME) || natts !=0 || ndims != 0 || 
	  var_type != NC_BYTE) ERR;
      if (nc_get_var_schar(ncid, varid, &schar_in)) ERR;
      if (schar_in != schar) ERR;
      if (nc_get_var_int(ncid, varid, &int_in)) ERR;
      if (int_in != schar) ERR;
      if (nc_get_var_long(ncid, varid, &long_in)) ERR;
      if (long_in != schar) ERR;
      if (nc_close(ncid)) ERR;
   }
   SUMMARIZE_ERR;
   printf ("*** Testing NC_USHORT conversions...");
   {
      /* Write a scalar NC_USHORT with value 65535, converted from various types. */
       unsigned short usval = 65535;
       int ival = 65535;
       long lval = 65535;
       float fval = 65535;
       double dval = 65535;
       int dimid;
       size_t coord[1];
       unsigned short ushort_in;
       int int_in;
       long long_in;
       float float_in;
       double double_in;
      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
      if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
      if (nc_def_var(ncid, VAR_NAME, NC_USHORT, 1, &dimid, &varid)) ERR;
      coord[0] = 1;
      if (nc_put_var1_int(ncid, varid, &coord[0], &ival)) ERR;
      coord[0] = 2;
      if (nc_put_var1_float(ncid, varid, &coord[0], &fval)) ERR;
      coord[0] = 3;
      if (nc_put_var1_double(ncid, varid, &coord[0], &dval)) ERR; 
      /* This cause a SIGABRT error */
      /*       coord[0] = 0; */
      /*       if (nc_put_var1_ushort(ncid, varid, &coord[0], &usval)) ERR; */

      if (nc_close(ncid)) ERR;

      /* Now open the file and check it. */
      if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
      if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, NULL, &natts)) ERR;
      if (strcmp(var_name, VAR_NAME) || natts !=0 || ndims != 1 || 
	  var_type != NC_USHORT) ERR;
      /* These also cause SIGABRT */
      /*       coord[0] = 1; */
      /*       if (nc_get_var1_int(ncid, varid, &coord[1], &int_in)) ERR; */
      /*       if (int_in != ival) ERR; */
      /*       coord[0] = 2; */
      /*       if (nc_get_var1_float(ncid, varid, &coord[2], &float_in)) ERR; */
      /*       if (float_in != fval) ERR; */
      /*       coord[0] = 3; */
      /*       if (nc_get_var1_double(ncid, varid, &coord[3], &double_in)) ERR; */
      /*       if (double_in != dval) ERR; */
      /*       coord[0] = 4; */
      /*       if (nc_get_var1_long(ncid, varid, &coord[4], &long_in)) ERR; */
      /*       if (long_in != lval) ERR; */
      /*       coord[0] = 0; */
      /*       if (nc_get_var1_ushort(ncid, varid, &coord[0], &ushort_in)) ERR; */
      /*       if (ushort_in != usval[0]) ERR; */
{'fraction_non_alphanumeric': 0.15283957079298613, 'fraction_numerical': 0.028264852132949488, 'mean_word_length': 2.482004555808656, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1424526', 'n_tokens_mistral': 3137, 'n_tokens_neox': 2994, 'n_words': 758}