summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-23 04:20:51 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-23 04:20:51 (GMT)
commit38a1ea7b99f61d07b667c6772ea6e998a7327013 (patch)
treec90232f3deb92b1ad5d5f85d0f628e67e0da1cf8 /hl
parent213ab6eb36e398b5d0db55df002875ffcdeb4122 (diff)
downloadhdf5-38a1ea7b99f61d07b667c6772ea6e998a7327013.zip
hdf5-38a1ea7b99f61d07b667c6772ea6e998a7327013.tar.gz
hdf5-38a1ea7b99f61d07b667c6772ea6e998a7327013.tar.bz2
[svn-r22130] Test for HDFFV-7777 h5ltget_attribure_string_f added
Added check that HLDS fortran function do remove NULL character.
Diffstat (limited to 'hl')
-rw-r--r--hl/fortran/test/tstds.f9010
-rw-r--r--hl/fortran/test/tstlite.f9053
2 files changed, 44 insertions, 19 deletions
diff --git a/hl/fortran/test/tstds.f90 b/hl/fortran/test/tstds.f90
index 8817989..c73e1c4 100644
--- a/hl/fortran/test/tstds.f90
+++ b/hl/fortran/test/tstds.f90
@@ -186,7 +186,10 @@ SUBROUTINE test_testds(err)
name_len = 25
name = ''
CALL H5DSget_scale_name_f(dsid, name, name_len, err)
- IF(err.LT.0.OR.name_len.NE.21.OR.TRIM(name).NE."Dimension Scale Set 1")THEN
+ IF(err.LT.0 .OR. &
+ name_len.NE.21 .OR. &
+ TRIM(name).NE."Dimension Scale Set 1" .OR. &
+ name(22:25).NE.' ')THEN
err = FAILED
CALL write_test_status(err)
RETURN
@@ -293,7 +296,10 @@ SUBROUTINE test_testds(err)
label_len = 25
label = ''
CALL H5DSget_label_f(did, DIM2, label, label_len, err)
- IF(err.LT.0.OR.label(1:label_len).NE."Label12".OR.label_len.NE.7)THEN
+ IF(err.LT.0.OR. &
+ label(1:label_len).NE."Label12" .OR. &
+ label_len.NE.7 .OR. &
+ label(8:25).NE.' ')THEN
err = FAILED
CALL write_test_status(err)
RETURN
diff --git a/hl/fortran/test/tstlite.f90 b/hl/fortran/test/tstlite.f90
index 9329dba..50be69e 100644
--- a/hl/fortran/test/tstlite.f90
+++ b/hl/fortran/test/tstlite.f90
@@ -1342,7 +1342,9 @@ SUBROUTINE test_attributes()
IMPLICIT NONE
CHARACTER(len=9), PARAMETER :: filename = "dsetf5.h5"! File name
+ CHARACTER(len=9), PARAMETER :: filename1 ="tattr.h5" ! C written attribute file
INTEGER(HID_T) :: file_id ! File identifier
+ INTEGER(HID_T) :: file_id1
INTEGER, PARAMETER :: DIM1 = 10; ! Dimension of array
CHARACTER(LEN=5), PARAMETER :: attrname1 = "attr1" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname2 = "attr2" ! Attribute name
@@ -1350,9 +1352,11 @@ SUBROUTINE test_attributes()
CHARACTER(LEN=5), PARAMETER :: attrname4 = "attr4" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname5 = "attr5" ! Attribute name
CHARACTER(LEN=8), PARAMETER :: buf1 = "mystring" ! Data buffer
+ CHARACTER(LEN=16), PARAMETER :: buf_c = "string attribute"
CHARACTER(LEN=8) :: bufr1 ! Data buffer
CHARACTER(LEN=10) :: bufr1_lg ! Data buffer
- CHARACTER(LEN=6) :: bufr1_sm ! Data buffer
+ CHARACTER(LEN=16) :: bufr_c ! Data buffer
+ CHARACTER(LEN=18) :: bufr_c_lg ! Data buffer
INTEGER, DIMENSION(DIM1) :: buf2 ! Data buffer
INTEGER, DIMENSION(DIM1) :: bufr2 ! Data buffer
REAL, DIMENSION(DIM1) :: buf3 ! Data buffer
@@ -1370,6 +1374,7 @@ SUBROUTINE test_attributes()
INTEGER :: rank = 1 ! Dataset rank
CHARACTER(LEN=5), PARAMETER :: dsetname1 = "dset1" ! Dataset name
INTEGER, DIMENSION(DIM1) :: buf ! Data buffer
+
!
! Initialize FORTRAN predefined datatypes.
@@ -1488,15 +1493,12 @@ SUBROUTINE test_attributes()
CALL passed()
-
-
!-------------------------------------------------------------------------
! string
!-------------------------------------------------------------------------
CALL test_begin(' Set/Get attributes string ')
-
!
! write attribute.
!
@@ -1530,19 +1532,36 @@ SUBROUTINE test_attributes()
STOP
ENDIF
- !
- ! read attribute into a fortran character buf that is smaller then buf1.
- !
- CALL h5ltget_attribute_string_f(file_id,dsetname1,attrname5,bufr1_sm,errcode)
-
- !
- ! compare read and write buffers.
- !
- IF ( buf1(1:6) .NE. bufr1_sm(1:6) ) THEN
- PRINT *, 'smaller read buffer differs from write buffer'
- PRINT *, buf1, ' and ', bufr1_sm
- STOP
- ENDIF
+ !
+ ! ** Test reading a string that was created with a C program **
+ !
+
+!!$ CALL h5fopen_f(filename1, H5F_ACC_RDONLY_F, file_id1, errcode)
+!!$
+!!$ CALL h5ltget_attribute_string_f(file_id1, "/", "attr5", bufr_c, errcode)
+!!$ !
+!!$ ! compare read and write buffers.
+!!$ !
+!!$ IF ( bufr_c .NE. buf_c ) THEN
+!!$ PRINT *, 'read buffer differs from write buffer'
+!!$ PRINT *, bufr1, ' and ', buf_c
+!!$ STOP
+!!$ ENDIF
+!!$ !
+!!$ ! read attribute into a fortran character buf that is larger then buf_c.
+!!$ !
+!!$ CALL h5ltget_attribute_string_f(file_id1, "/", "attr5", bufr_c_lg, errcode)
+!!$
+!!$ !
+!!$ ! compare read and write buffers, make sure C NULL character was removed.
+!!$ !
+!!$ IF ( buf_c(1:16) .NE. bufr_c_lg(1:16) .AND. bufr_c_lg(17:18) .NE. ' ' ) THEN
+!!$ PRINT *, 'larger read buffer differs from write buffer'
+!!$ PRINT *, buf_c, ' and ', bufr_c_lg
+!!$ STOP
+!!$ ENDIF
+
+ CALL h5fclose_f(file_id1, errcode)
CALL passed()