Sha256: f16c7362f9fd04e9684a9b3d4d3875443070c7e3df362446fd53e00ac690e718

Contents?: true

Size: 930 Bytes

Versions: 9

Compression:

Stored size: 930 Bytes

Contents

require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')

class TestSocket < Test::Unit::TestCase
  def test_simple
    socket = WorkQueue::Socket.new 

    socket.write 1
    socket.write 2
    socket.write "STRING"
    socket.write :string

    assert_equal 1, socket.read
    assert_equal 2, socket.read
    assert_equal "STRING", socket.read
    assert_equal :string, socket.read

    socket.close_write
    assert_raise ClosedStream do
      socket.read
    end
  end

  def __test_speed
    socket = WorkQueue::Socket.new 

    num = 10_000

    Thread.new do
      num.times do |i|
        socket.write nil
      end
      socket.write DoneProcessing.new 
    end

    bar = Log::ProgressBar.new num
    while true
      i = socket.read
      bar.tick
      break if DoneProcessing === i
    end
    bar.done
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scout-gear-10.4.0 test/scout/work_queue/test_socket.rb
scout-gear-10.3.0 test/scout/work_queue/test_socket.rb
scout-gear-10.2.0 test/scout/work_queue/test_socket.rb
scout-gear-10.1.0 test/scout/work_queue/test_socket.rb
scout-gear-10.0.1 test/scout/work_queue/test_socket.rb
scout-gear-9.1.0 test/scout/work_queue/test_socket.rb
scout-gear-9.0.0 test/scout/work_queue/test_socket.rb
scout-gear-8.1.0 test/scout/work_queue/test_socket.rb
scout-gear-8.0.0 test/scout/work_queue/test_socket.rb