Skip to content

Commit d809c24

Browse files
author
blackhedd
committed
test development
1 parent 0871f7b commit d809c24

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/testsnmp.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,40 @@
55

66
$:.unshift "lib"
77

8-
require 'net/ldap'
8+
require 'net/snmp'
99
require 'stringio'
1010

1111

1212
class TestSnmp < Test::Unit::TestCase
1313

14+
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"
15+
1416
def setup
1517
end
1618

1719
def teardown
1820
end
1921

22+
def test_invalid_packet
23+
data = "xxxx"
24+
assert_raise( Net::BER::BerError ) {
25+
ary = data.read_ber(Net::SNMP::AsnSyntax)
26+
}
27+
28+
end
29+
30+
def test_consume_string
31+
data = "xxx"
32+
assert_equal( nil, data.read_ber! )
33+
assert_equal( "xxx", data )
34+
35+
data = SnmpRequest + "!!!"
36+
ary = data.read_ber!( Net::SNMP::AsnSyntax )
37+
assert_equal( "!!!", data )
38+
assert ary.is_a?(Array)
39+
assert ary.is_a?(Net::BER::BerIdentifiedArray)
40+
end
41+
2042
end
2143

2244

0 commit comments

Comments
 (0)