From 3f14b540145b894c5e7ee8f92bdc9161c22f3e48 Mon Sep 17 00:00:00 2001 From: blackhedd Date: Fri, 15 Dec 2006 14:12:02 +0000 Subject: [PATCH] added some more test cases --- lib/net/snmp.rb | 1 + tests/testsnmp.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/net/snmp.rb b/lib/net/snmp.rb index 945db94..06d251e 100644 --- a/lib/net/snmp.rb +++ b/lib/net/snmp.rb @@ -88,6 +88,7 @@ module Net @pdu_type = args[:pdu_type] # leave nil unless specified; there's no reasonable default value. @error_status = args[:error_status] || 0 @error_index = args[:error_index] || 0 + @variables = args[:variables] || [] end #-- diff --git a/tests/testsnmp.rb b/tests/testsnmp.rb index 04b5a2a..f46609c 100644 --- a/tests/testsnmp.rb +++ b/tests/testsnmp.rb @@ -75,6 +75,8 @@ class TestSnmp < Test::Unit::TestCase def test_malformations pdu = Net::SnmpPdu.new + pdu.version = 0 + pdu.version = 2 assert_raise( Net::SnmpPdu::Error ) { pdu.version = 100 } @@ -102,6 +104,15 @@ class TestSnmp < Test::Unit::TestCase assert_equal( SnmpGetResponse, pdu.to_ber_string ) end + def test_make_bad_response + pdu = Net::SnmpPdu.new + assert_raise(Net::SnmpPdu::Error) {pdu.to_ber_string} + pdu.pdu_type = :get_response + pdu.request_id = 999 + pdu.to_ber_string + # Not specifying variables doesn't create an error. (Maybe it should?) + end + end