Implement BSON::ByteBuffer#==
This commit is contained in:
parent
08daf9c5f9
commit
6b4ca2461f
|
@ -231,6 +231,10 @@ module BSON
|
|||
def more?
|
||||
@cursor < @str.size
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
other.respond_to?(:to_s) && @str == other.to_s
|
||||
end
|
||||
|
||||
def to_a
|
||||
@str.unpack("C*")
|
||||
|
|
|
@ -186,5 +186,16 @@ class ByteBufferTest < Test::Unit::TestCase
|
|||
@buf.get_int
|
||||
assert !@buf.more?
|
||||
end
|
||||
|
||||
def test_equality
|
||||
@buf = ByteBuffer.new("foo")
|
||||
assert_equal @buf, @buf
|
||||
assert_equal ByteBuffer.new(""), ByteBuffer.new("")
|
||||
assert_equal ByteBuffer.new("123"), ByteBuffer.new("123")
|
||||
assert_not_equal ByteBuffer.new("123"), ByteBuffer.new("1234")
|
||||
assert_equal @buf, "foo"
|
||||
assert_not_equal @buf, 123
|
||||
assert_not_equal @buf, nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue