Sha256: 12c523dd27a0dc09f7e3613d221dd62d1625abcfe2cf987b8f8c8bb057b62995

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo'
require 'test/unit'

class MessageTest < Test::Unit::TestCase

  include Mongo

  def setup
    @msg = Message.new(42)
  end

  def test_initial_info
    assert_equal Message::HEADER_SIZE, @msg.buf.length
    @msg.write_long(1029)
    @msg.buf.rewind
    assert_equal Message::HEADER_SIZE + 8, @msg.buf.get_int
    @msg.buf.get_int            # skip message id
    assert_equal 0, @msg.buf.get_int
    assert_equal 42,  @msg.buf.get_int
    assert_equal 1029, @msg.buf.get_long
  end

  def test_update_length
    @msg.update_message_length
    @msg.buf.rewind
    assert_equal Message::HEADER_SIZE, @msg.buf.get_int
  end

  def test_long_length
    @msg.write_long(1027)
    assert_equal Message::HEADER_SIZE + 8, @msg.buf.length
  end

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
mongodb-mongo-0.13 test/test_message.rb
mongodb-mongo-0.14.1 test/test_message.rb
mongodb-mongo-0.14 test/test_message.rb
pahagon-mongo-abd-0.14.1 test/test_message.rb
mongo-0.15.1 test/test_message.rb
mongo-0.15 test/test_message.rb