Sha256: 58cc020be560baf819c71591c59242c1ececa328668bb2e5f5981ced58bc56eb

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

# This file is part of Libusb for Ruby.
#
# Libusb for Ruby is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Libusb for Ruby is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Libusb for Ruby.  If not, see <http://www.gnu.org/licenses/>.

require "minitest/autorun"
require "libusb"

class TestLibusbIsoTransfer < Minitest::Test
  include LIBUSB

  def setup
    c = Context.new
    begin
      @dev = c.devices.first.open
    rescue LIBUSB::ERROR_ACCESS
      @dev = nil
      skip "error opening device"
    end
  end

  def teardown
    @dev.close if @dev
  end

  def test_iso_transfer
    tr = IsochronousTransfer.new 10, dev_handle: @dev
    assert_equal 10, tr.num_packets, "number of packets should match"

    tr.buffer = " "*130
    tr.packet_lengths = 13
    tr[7].length = 12
    assert_equal 12, tr[7].length, "packet length should be set"
    assert_equal 13, tr[8].length, "packet length should be set"

    assert_raises(LIBUSB::ERROR_IO, "the randomly choosen device will probably not handle iso transfer") do
      tr.submit!
    end
  end

  def test_max_alt_packet_size
    d = Context.new.devices[0]
    size = d.max_alt_packet_size d.interfaces[0], d.settings[0], d.endpoints[0]
    assert_operator 0, :<=, size
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
libusb-0.7.2 test/test_libusb_iso_transfer.rb
libusb-0.7.2-x64-mingw-ucrt test/test_libusb_iso_transfer.rb
libusb-0.7.2-x64-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.2-x86-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.1 test/test_libusb_iso_transfer.rb
libusb-0.7.1-x64-mingw-ucrt test/test_libusb_iso_transfer.rb
libusb-0.7.1-x64-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.1-x86-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.0-x86-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.0-x64-mingw32 test/test_libusb_iso_transfer.rb
libusb-0.7.0-x64-mingw-ucrt test/test_libusb_iso_transfer.rb
libusb-0.7.0 test/test_libusb_iso_transfer.rb