pulled in some attribute testing that got missed in recent merges
@@ -283,6 +283,54 @@ main(int argc, char **argv)
if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, too_long_name) != NC_EMAXNAME) ERR;
if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, OLD_NAME_2) != NC_ENAMEINUSE) ERR;
+ if (nc_put_att_text(ncid, NC_GLOBAL, OLD_NAME, strlen(CONTENTS),
+ NULL) != NC_EINVAL) ERR;
+ {
+ /* Check that the NC_GLOBAL reserved words are rejected. */
+ const char** reserved = NC_RESERVED_ATT_LIST;
+ for ( ; *reserved; reserved++)
+ {
+ if (nc_put_att_text(ncid, NC_GLOBAL, *reserved, strlen(CONTENTS),
+ CONTENTS) != NC_ENAMEINUSE) ERR;
+ }
+ }
+ {
+ /* Check that the variable reserved words are rejected. */
+ const char** reserved = NC_RESERVED_VARATT_LIST;
+ for ( ; *reserved; reserved++)
+ {
+ if (nc_put_att_text(ncid, 0, *reserved, strlen(CONTENTS),
+ CONTENTS) != NC_ENAMEINUSE) ERR;
+ }
+ }
+ {
+ /* Check that the read-only reserved words are rejected. */
+ const char** reserved = NC_RESERVED_SPECIAL_LIST;
+ for ( ; *reserved; reserved++)
+ {
+ if (nc_put_att_text(ncid, NC_GLOBAL, *reserved, strlen(CONTENTS),
+ CONTENTS) != NC_ENAMEINUSE) ERR;
+ }
+ }
+
+ /* Write the attribute at last. */
+ if (nc_put_att_text(ncid, NC_GLOBAL, OLD_NAME, strlen(CONTENTS),
+ CONTENTS)) ERR;
+
+ /* Write another with different name. */
+ if (nc_put_att_text(ncid, NC_GLOBAL, OLD_NAME_2, strlen(CONTENTS),
+ CONTENTS)) ERR;
+
+ /* These will not work. */
+ if (nc_rename_att(ncid + TEST_VAL_42, NC_GLOBAL, OLD_NAME, NEW_NAME) != NC_EBADID) ERR;
+ if (nc_rename_att(ncid, TEST_VAL_42, OLD_NAME, NEW_NAME) != NC_ENOTVAR) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, NULL) != NC_EINVAL) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, NULL, NEW_NAME) != NC_EINVAL) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, NULL, NULL) != NC_EINVAL) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, BAD_NAME) != NC_EBADNAME) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, too_long_name) != NC_EMAXNAME) ERR;
+ if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, OLD_NAME_2) != NC_ENAMEINUSE) ERR;
+
/* Rename the att. */
if (nc_rename_att(ncid, NC_GLOBAL, OLD_NAME, NEW_NAME)) ERR;
