diff options
Diffstat (limited to 'lib/snmp/test/snmp_pdus_test.erl')
-rw-r--r-- | lib/snmp/test/snmp_pdus_test.erl | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/lib/snmp/test/snmp_pdus_test.erl b/lib/snmp/test/snmp_pdus_test.erl index d5add50f52..6dc5b779aa 100644 --- a/lib/snmp/test/snmp_pdus_test.erl +++ b/lib/snmp/test/snmp_pdus_test.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -37,6 +37,7 @@ all/1, tickets/1, otp7575/1, + otp8563/1, init_per_testcase/2, fin_per_testcase/2 ]). @@ -66,6 +67,7 @@ init_per_testcase(_Case, Config) when is_list(Config) -> fin_per_testcase(_Case, Config) when is_list(Config) -> Config. + %%====================================================================== %% Test case definitions %%====================================================================== @@ -76,7 +78,8 @@ all(suite) -> tickets(suite) -> [ - otp7575 + otp7575, + otp8563 ]. @@ -118,6 +121,55 @@ otp7575(Config) when is_list(Config) -> ok. +otp8563(suite) -> []; +otp8563(doc) -> ["OTP-8563"]; +otp8563(Config) when is_list(Config) -> + Val1 = 16#7fffffffffffffff, + io:format("try encode and decode ~w~n", [Val1]), + Enc1 = snmp_pdus:enc_value('Counter64', Val1), + {{'Counter64', Val1}, []} = snmp_pdus:dec_value(Enc1), + + Val2 = Val1 + 1, + io:format("try encode and decode ~w~n", [Val2]), + Enc2 = snmp_pdus:enc_value('Counter64', Val2), + {{'Counter64', Val2}, []} = snmp_pdus:dec_value(Enc2), + + Val3 = Val2 + 1, + io:format("try encode and decode ~w~n", [Val3]), + Enc3 = snmp_pdus:enc_value('Counter64', Val3), + {{'Counter64', Val3}, []} = snmp_pdus:dec_value(Enc3), + + Val4 = 16#fffffffffffffffe, + io:format("try encode and decode ~w~n", [Val4]), + Enc4 = snmp_pdus:enc_value('Counter64', Val4), + {{'Counter64', Val4}, []} = snmp_pdus:dec_value(Enc4), + + Val5 = Val4 + 1, + io:format("try encode and decode ~w~n", [Val5]), + Enc5 = snmp_pdus:enc_value('Counter64', Val5), + {{'Counter64', Val5}, []} = snmp_pdus:dec_value(Enc5), + + Val6 = 16#ffffffffffffffff + 1, + io:format("try and fail to encode ~w~n", [Val6]), + case (catch snmp_pdus:enc_value('Counter64', Val6)) of + {'EXIT', {error, {bad_counter64, Val6}}} -> + ok; + Unexpected6 -> + exit({unexpected_encode_result, Unexpected6, Val6}) + end, + + Val7 = -1, + io:format("try and fail to encode ~w~n", [Val7]), + case (catch snmp_pdus:enc_value('Counter64', Val7)) of + {'EXIT', {error, {bad_counter64, Val7}}} -> + ok; + Unexpected7 -> + exit({unexpected_encode_result, Unexpected7, Val7}) + end, + + ok. + + %%====================================================================== %% Internal functions %%====================================================================== |