1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 1997-2016. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20%%
21-module(testSeqOptional).
22
23-include("External.hrl").
24-export([main/1]).
25
26-include_lib("common_test/include/ct.hrl").
27
28-record('SeqOpt1',{bool1 = asn1_NOVALUE, int1, seq1 = asn1_NOVALUE}).
29-record('SeqOpt1Imp',{bool1 = asn1_NOVALUE, int1, seq1 = asn1_NOVALUE}).
30-record('SeqOpt1Exp',{bool1 = asn1_NOVALUE, int1, seq1 = asn1_NOVALUE}).
31-record('SeqOpt2',{seq2 = asn1_NOVALUE, bool2, int2}).
32-record('SeqOpt2Imp',{seq2 = asn1_NOVALUE, bool2, int2}).
33-record('SeqOpt2Exp',{seq2 = asn1_NOVALUE, bool2, int2}).
34-record('SeqOpt3',{bool3 = asn1_NOVALUE, seq3 = asn1_NOVALUE, int3 = asn1_NOVALUE}).
35-record('SeqOpt3Imp',{bool3 = asn1_NOVALUE, seq3 = asn1_NOVALUE, int3 = asn1_NOVALUE}).
36-record('SeqOpt3Exp',{bool3 = asn1_NOVALUE, seq3 = asn1_NOVALUE, int3 = asn1_NOVALUE}).
37-record('SeqIn',{boolIn, intIn}).
38-record('SeqChoOpt',{int, cho = asn1_NOVALUE}).
39
40main(_Rules) ->
41    roundtrip('SeqOpt1', #'SeqOpt1'{bool1=true,int1=15,
42				    seq1=#'SeqIn'{boolIn=true,intIn=66}}),
43    roundtrip('SeqOpt1', #'SeqOpt1'{bool1=asn1_NOVALUE,
44				    int1=15,seq1=asn1_NOVALUE}),
45    roundtrip('SeqOpt2', #'SeqOpt2'{seq2=#'SeqIn'{boolIn=true,intIn=66},
46				    bool2=true,int2=15}),
47    roundtrip('SeqOpt2', #'SeqOpt2'{seq2=asn1_NOVALUE,bool2=true,int2=15}),
48    roundtrip('SeqOpt3', #'SeqOpt3'{bool3=true,
49				    seq3=#'SeqIn'{boolIn=true,
50						  intIn=66},int3=15}),
51    roundtrip('SeqOpt3', #'SeqOpt3'{bool3=asn1_NOVALUE,
52				    seq3=asn1_NOVALUE,int3=15}),
53    roundtrip('SeqOpt1Imp', #'SeqOpt1Imp'{bool1=true,int1=15,
54              seq1=#'SeqIn'{boolIn=true,intIn=66}}),
55    roundtrip('SeqOpt1Imp', #'SeqOpt1Imp'{bool1=asn1_NOVALUE,
56					  int1=15,seq1=asn1_NOVALUE}),
57    roundtrip('SeqOpt2Imp', #'SeqOpt2Imp'{seq2=#'SeqIn'{boolIn=true,intIn=66},
58					  bool2=true,int2=15}),
59    roundtrip('SeqOpt2Imp', #'SeqOpt2Imp'{seq2=asn1_NOVALUE,
60					  bool2=true,int2=15}),
61    roundtrip('SeqOpt3Imp', #'SeqOpt3Imp'{bool3=true,
62					  seq3=#'SeqIn'{boolIn=true,intIn=66},
63					  int3=15}),
64    roundtrip('SeqOpt3Imp', #'SeqOpt3Imp'{bool3=asn1_NOVALUE,
65					  seq3=asn1_NOVALUE,int3=15}),
66    roundtrip('SeqOpt1Exp', #'SeqOpt1Exp'{bool1=true,int1=15,
67					  seq1=#'SeqIn'{boolIn=true,
68							intIn=66}}),
69    roundtrip('SeqOpt1Exp', #'SeqOpt1Exp'{bool1=asn1_NOVALUE,
70					  int1=15,seq1=asn1_NOVALUE}),
71    roundtrip('SeqOpt2Exp', #'SeqOpt2Exp'{seq2=#'SeqIn'{boolIn=true,intIn=66},
72					  bool2=true,int2=15}),
73    roundtrip('SeqOpt2Exp', #'SeqOpt2Exp'{seq2=asn1_NOVALUE,
74					  bool2=true,int2=15}),
75    roundtrip('SeqOpt3Exp', #'SeqOpt3Exp'{bool3=true,
76					  seq3=#'SeqIn'{boolIn=true,intIn=66},
77					  int3=15}),
78    roundtrip('SeqOpt3Exp', #'SeqOpt3Exp'{bool3=asn1_NOVALUE,
79					  seq3=asn1_NOVALUE,int3=15}),
80    roundtrip('SeqChoOpt', #'SeqChoOpt'{int=15,cho={boolC,true}}),
81    roundtrip('SeqChoOpt', #'SeqChoOpt'{int=15,cho=asn1_NOVALUE}),
82    ok.
83
84roundtrip(Type, Value) ->
85    asn1_test_lib:roundtrip('SeqOptional', Type, Value).
86