Skip to content

Commit e169986

Browse files
committed
char read: add nullpad and variable test cases
1 parent 0393352 commit e169986

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tests/test_string.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
fn = Path(P.file).expanduser()
1616

1717
with h5py.File(fn, "w") as f:
18-
f["/str"] = "Hello World!"
18+
f["/variable"] = "Hello World!"
19+
f.create_dataset("/nullpad", dtype="S40", data="Hello World!")

tests/test_string_read.f90

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ program main
44

55
implicit none (type, external)
66

7-
character(1000) :: pyp, str
7+
character(1000) :: pyp, vstr, fstr
88
integer :: i
99

1010
type(hdf5_file) :: h
@@ -14,12 +14,14 @@ program main
1414

1515
call h%open(pyp, "r")
1616

17-
call h%read("/str", str)
17+
call h%read("/variable", vstr)
18+
if(vstr /= "Hello World!") error stop "h5py read variable length failed: " // trim(vstr)
1819

19-
call h%close()
20+
call h%read("/nullpad", fstr)
21+
if(fstr /= "Hello World!") error stop "h5py read null pad failed: " // trim(fstr)
2022

21-
if(str /= "Hello World!") error stop "h5py read failed: " // trim(str)
23+
call h%close()
2224

23-
print *, "OK: variable length string read"
25+
print *, "OK: variable/nullpad length string read"
2426

2527
end program

0 commit comments

Comments
 (0)