Skip to content

Commit

Permalink
asn1: add test case for exclusive decode with undec_rest option
Browse files Browse the repository at this point in the history
  • Loading branch information
vances committed Oct 5, 2024
1 parent f97dc07 commit 85c2317
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/asn1/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ MODULES= \
testDER \
test_selective_decode \
test_special_decode_performance \
test_exclusive_decode_rest \
testTCAP \
testSSLspecs \
testSelectionTypes \
Expand Down
8 changes: 8 additions & 0 deletions lib/asn1/test/asn1_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ all() ->
test_undecoded_rest,
specialized_decodes,
special_decode_performance,
exclusive_decode_rest,

testMegaco,
testConstraints,
Expand Down Expand Up @@ -967,6 +968,13 @@ special_decode_performance(Config, Rule, Opts) ->
asn1_test_lib:compile_all(Files, Config, [Rule, asn1config|Opts]),
test_special_decode_performance:go(all).

exclusive_decode_rest(Config) ->
test(Config, fun exclusive_decode_rest/3, [ber]).
exclusive_decode_rest(Config, Rule, Opts) ->
asn1_test_lib:compile("SwCDR.py", Config,
[Rule, undec_rest, asn1config|Opts]),
test_exclusive_decode_rest:test().

test_ParamTypeInfObj(Config) ->
asn1_test_lib:compile("IN-CS-1-Datatypes", Config, [ber]).

Expand Down
6 changes: 6 additions & 0 deletions lib/asn1/test/asn1_SUITE_data/SwCDR.asn1config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{exclusive_decode,
{'SwCDR',
[{decode_cdr,
['SwCDR',
[{origSvcCallRecord, undecoded},
{termSvcCallRecord, undecoded}]]}]}}.
35 changes: 35 additions & 0 deletions lib/asn1/test/test_exclusive_decode_rest.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2003-2024. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%
%%
-module(test_exclusive_decode_rest).
-export([test/0]).

test() ->
{ok, CDR} = 'SwCDR':encode('SwCDR', {origSvcCallRecord, orig_cdr()}),
Bin = <<CDR/binary, CDR/binary>>,
{ok, {origSvcCallRecord, _}, CDR} = 'SwCDR':decode_cdr(Bin).

orig_cdr() ->
{'OrigSvcCallRecord', 1, 2, 3, <<145,65,97,85,21,50,244>>,
<<145,65,97,85,85,118,248>>, <<145,65,97,85,85,118,248>>,
<<2,0,2,4,1,0,0,5>>, <<2,0,3,2,4,5>>, 35000, 0, 0, 0, 3600,
3600, 3600, 3600, 48, 48, 64, 64, 20, 20, 12, 12, 20, 20,
4, 4, 1, 1, 3600, 3600, asn1_NOVALUE}.

0 comments on commit 85c2317

Please sign in to comment.