ruby-net-ldap/tests/testsnmp.rb

45 lines
776 B
Ruby
Raw Normal View History

2006-12-15 11:03:27 +01:00
# $Id$
#
#
$:.unshift "lib"
2006-12-15 11:36:17 +01:00
require 'net/snmp'
2006-12-15 11:03:27 +01:00
require 'stringio'
class TestSnmp < Test::Unit::TestCase
2006-12-15 11:36:17 +01:00
SnmpRequest = "0'\002\001\000\004\006public\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
2006-12-15 11:03:27 +01:00
def setup
end
def teardown
end
2006-12-15 11:36:17 +01:00
def test_invalid_packet
data = "xxxx"
assert_raise( Net::BER::BerError ) {
ary = data.read_ber(Net::SNMP::AsnSyntax)
}
end
def test_consume_string
data = "xxx"
assert_equal( nil, data.read_ber! )
assert_equal( "xxx", data )
data = SnmpRequest + "!!!"
ary = data.read_ber!( Net::SNMP::AsnSyntax )
assert_equal( "!!!", data )
assert ary.is_a?(Array)
assert ary.is_a?(Net::BER::BerIdentifiedArray)
end
2006-12-15 11:03:27 +01:00
end