Sha256: cb466a98a03125d513fae1fe420e43965c463e24548c91bc569cc98d9a663158

Contents?: true

Size: 940 Bytes

Versions: 4

Compression:

Stored size: 940 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
    sss 0
    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

4 entries across 4 versions & 1 rubygems

Version Path
scout-gear-7.3.0 test/scout/work_queue/test_socket.rb
scout-gear-7.2.0 test/scout/work_queue/test_socket.rb
scout-gear-7.1.0 test/scout/work_queue/test_socket.rb
scout-gear-6.0.0 test/scout/work_queue/test_socket.rb