Sha256: ebfd1272542f1ac59d86165df9c121d7bd6d6ea761573a850c5877f2c279e3f5

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net

require 'mu/testcase'
require 'mu/pcap/io_pair'

module Mu
class Pcap
class IOPair
class Test < Mu::TestCase

    def test_stream
        io1, io2 = IOPair.stream_pair

        # send
        assert_equal 3, io1.write("foo")
        assert_equal "foo", io2.read(3)

        # another
        assert_equal 3, io1.write("bar")
        assert_equal "bar", io2.read(0xffff)

        # reverse
        assert_equal 3, io2.write("baz")
        assert_equal "baz", io1.read(0xffff)

        # 2 sends, 1 receive
        assert_equal 3, io1.write("one")
        assert_equal 3, io1.write("two")
        assert_equal "onetwo", io2.read(6)
    end

    def test_packet
        io1, io2 = IOPair.packet_pair

        # send
        assert_equal 3, io1.write("foo")
        assert_equal "foo", io2.read

        # another
        assert_equal 3, io1.write("bar")
        assert_equal "bar", io2.read

        # reverse
        assert_equal 3, io2.write("baz")
        assert_equal "baz", io1.read

        # 2 sends, 2 receives
        assert_equal 3, io1.write("one")
        assert_equal 3, io1.write("two")
        assert_equal "one", io2.read
        assert_equal "two", io2.read
    end
end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pcapr-local-0.2.0 test/mu/pcap/tc_pair.rb
pcapr-local-0.1.13 test/mu/pcap/tc_pair.rb
pcapr-local-0.1.12 test/mu/pcap/tc_pair.rb
pcapr-local-0.1.11 test/mu/pcap/tc_pair.rb
pcapr-local-0.1.10 test/mu/pcap/tc_pair.rb