Skip to content

Commit

Permalink
Wrap the libopenmpt module metadata functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Aug 25, 2018
1 parent a9ba2dd commit 0c8f3aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ffi/openmpt/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ module API

# Informational/error module calls
attach_function :openmpt_module_get_duration_seconds, [:pointer], :double
attach_function :openmpt_module_get_metadata_keys, [:pointer], :pointer
attach_function :openmpt_module_get_metadata,
[:pointer, :string], :pointer
attach_function :openmpt_module_error_get_last, [:pointer], :int
attach_function :openmpt_module_error_set_last, [:pointer, :int], :void
attach_function :openmpt_module_error_get_last_message,
Expand Down
17 changes: 17 additions & 0 deletions test/openmpt_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ def test_module_get_duration
end
end

def test_module_metadata
module_test(MOD_LAST_SUN) do |mod|
keys = openmpt_module_get_metadata_keys(mod)
refute_equal keys.read_string, ''
assert keys.read_string.include?(';')
openmpt_free_string(keys)

data = openmpt_module_get_metadata(mod, 'type')
assert_equal data.read_string, 'mod'
openmpt_free_string(data)

data = openmpt_module_get_metadata(mod, 'xxxx')
assert_equal data.read_string, ''
openmpt_free_string(data)
end
end

def test_get_set_module_errors
module_test(MOD_LAST_SUN) do |mod|
errno = openmpt_module_error_get_last(mod)
Expand Down

0 comments on commit 0c8f3aa

Please sign in to comment.