Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests updated to deal with faster input

  • Loading branch information...
commit 323d45bb798274720796eddcb53e2b6926f0fe95 1 parent 6eb9730
@arirusso authored
Showing with 30 additions and 9 deletions.
  1. +1 −1  test/test_input_buffer.rb
  2. +29 −8 test/test_io.rb
View
2  test/test_input_buffer.rb
@@ -36,7 +36,7 @@ def test_input_buffer
end
- assert_equal(input.buffer.length, messages.length)
+ assert_equal(bytes.length, input.buffer.map { |m| m[:data] }.flatten.length)
end
end
View
37 test/test_io.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require "helper"
+require 'helper'
class IoTest < Test::Unit::TestCase
@@ -8,10 +8,13 @@ class IoTest < Test::Unit::TestCase
include TestHelper
include TestHelper::Config # before running these tests, adjust the constants in config.rb to suit your hardware setup
# ** this test assumes that TestOutput is connected to TestInput
- def test_full_io
+ def test_full_io
+ sleep(1)
messages = VariousMIDIMessages
-
+ messages_arr = messages.inject { |a,b| a+b }.flatten
+ received_arr = []
+ pointer = 0
TestOutput.open do |output|
TestInput.open do |input|
@@ -20,13 +23,21 @@ def test_full_io
$>.puts "sending: " + msg.inspect
output.puts(msg)
+ sleep(1)
+ received = input.gets.map { |m| m[:data] }.flatten
+
- received = input.gets.first[:data]
$>.puts "received: " + received.inspect
- assert_equal(msg, received)
+ assert_equal(messages_arr.slice(pointer, received.length), received)
+
+ pointer += received.length
+
+ received_arr += received
end
+
+ assert_equal(messages_arr.length, received_arr.length)
end
end
@@ -37,6 +48,9 @@ def test_full_io_bytestr
sleep(1) # pause between tests
messages = VariousMIDIByteStrMessages
+ messages_str = messages.join
+ received_str = ""
+ pointer = 0
TestOutput.open do |output|
TestInput.open do |input|
@@ -46,13 +60,20 @@ def test_full_io_bytestr
$>.puts "sending: " + msg.inspect
output.puts(msg)
-
- received = input.gets_bytestr.first[:data]
+ sleep(1)
+ received = input.gets_bytestr.map { |m| m[:data] }.flatten.join
$>.puts "received: " + received.inspect
- assert_equal(msg, received)
+ assert_equal(messages_str.slice(pointer, received.length), received)
+
+ pointer += received.length
+
+ received_str += received
end
+
+ assert_equal(messages_str, received_str)
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.