Skip to content

Commit

Permalink
Add simple testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Sep 7, 2024
1 parent 0e1e4c2 commit c654a93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Binary file added test/fixtures/example.h5
Binary file not shown.
15 changes: 15 additions & 0 deletions test/hdf5_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ class HDF5Test < Test::Unit::TestCase
assert_equal(10, minor.read_int)
assert_kind_of(Integer, release.read_int)
end

test 'example' do
f = HDF5::File.new(File.join(__dir__, 'fixtures', 'example.h5'))
assert_equal(%w[foo], f.list_entries)
g = f['foo']
assert_equal(%w[bar_float bar_int], g.list_datasets)
d = g['bar_float']
assert_equal([10], d.shape)
assert_equal(:H5T_FLOAT, d.dtype)
assert_equal([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], d.read)
d = g['bar_int']
assert_equal([10], d.shape)
assert_equal(:H5T_INTEGER, d.dtype)
assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], d.read)
end
end

0 comments on commit c654a93

Please sign in to comment.