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(testSeqDefault).
22
23-include("External.hrl").
24-export([main/1]).
25
26-include_lib("common_test/include/ct.hrl").
27
28-record('SeqDef1',{bool1 = asn1_DEFAULT, int1, seq1 = asn1_DEFAULT}).
29-record('SeqDef1Imp',{bool1 = asn1_DEFAULT, int1, seq1 = asn1_DEFAULT}).
30-record('SeqDef1Exp',{bool1 = asn1_DEFAULT, int1, seq1 = asn1_DEFAULT}).
31-record('SeqDef2',{seq2 = asn1_DEFAULT, bool2 = asn1_DEFAULT, int2}).
32-record('SeqDef2Imp',{seq2 = asn1_DEFAULT, bool2 = asn1_DEFAULT, int2}).
33-record('SeqDef2Exp',{seq2 = asn1_DEFAULT, bool2, int2}).
34-record('SeqDef3',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}).
35-record('SeqDef3Imp',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}).
36-record('SeqDef3Exp',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}).
37-record('SeqIn',{boolIn = asn1_NOVALUE, intIn = 12}).
38
39
40main(_Rules) ->
41    roundtrip('SeqDef1', #'SeqDef1'{bool1=true,int1=15,seq1=#'SeqIn'{boolIn=true,intIn=66}}),
42    roundtrip('SeqDef1',
43	      #'SeqDef1'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT},
44	      #'SeqDef1'{bool1=true,int1=15,seq1=#'SeqIn'{}}),
45
46    roundtrip('SeqDef2', #'SeqDef2'{seq2=#'SeqIn'{boolIn=true,intIn=66},bool2=true,int2=15}),
47    roundtrip('SeqDef2',
48	      #'SeqDef2'{seq2=asn1_DEFAULT,bool2=asn1_DEFAULT,int2=15},
49	      #'SeqDef2'{seq2=#'SeqIn'{},bool2=true,int2=15}),
50
51    roundtrip('SeqDef3', #'SeqDef3'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}),
52    roundtrip('SeqDef3',
53	      #'SeqDef3'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15},
54	      #'SeqDef3'{bool3=true,seq3=#'SeqIn'{},int3=15}),
55
56    roundtrip('SeqDef1Imp', #'SeqDef1Imp'{bool1=true,int1=15,
57              seq1=#'SeqIn'{boolIn=true,intIn=66}}),
58    roundtrip('SeqDef1Imp',
59	      #'SeqDef1Imp'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT},
60	      #'SeqDef1Imp'{bool1=true,int1=15,seq1=#'SeqIn'{}}),
61
62    roundtrip('SeqDef2Imp', #'SeqDef2Imp'{seq2=#'SeqIn'{boolIn=true,intIn=66},
63					  bool2=true,int2=15}),
64    roundtrip('SeqDef2Imp',
65	      #'SeqDef2Imp'{seq2=asn1_DEFAULT,bool2=asn1_DEFAULT,int2=15},
66	      #'SeqDef2Imp'{seq2=#'SeqIn'{},bool2=true,int2=15}),
67
68    roundtrip('SeqDef3Imp',
69	      #'SeqDef3Imp'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}),
70    roundtrip('SeqDef3Imp',
71	      #'SeqDef3Imp'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15},
72	      #'SeqDef3Imp'{bool3=true,seq3=#'SeqIn'{},int3=15}),
73
74    roundtrip('SeqDef1Exp',
75	      #'SeqDef1Exp'{bool1=true,int1=15,seq1=#'SeqIn'{boolIn=true,intIn=66}}),
76    roundtrip('SeqDef1Exp',
77	      #'SeqDef1Exp'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT},
78	      #'SeqDef1Exp'{bool1=true,int1=15,seq1=#'SeqIn'{}}),
79
80    roundtrip('SeqDef2Exp', #'SeqDef2Exp'{seq2=#'SeqIn'{boolIn=true,intIn=66},
81              bool2=true,int2=15}),
82    roundtrip('SeqDef2Exp',
83	      #'SeqDef2Exp'{seq2=asn1_DEFAULT,bool2=true,int2=15},
84	      #'SeqDef2Exp'{seq2=#'SeqIn'{},bool2=true,int2=15}),
85
86    roundtrip('SeqDef3Exp',
87	      #'SeqDef3Exp'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}),
88    roundtrip('SeqDef3Exp',
89	      #'SeqDef3Exp'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15},
90	      #'SeqDef3Exp'{bool3=true,seq3=#'SeqIn'{},int3=15}),
91    ok.
92
93roundtrip(Type, Value) ->
94    roundtrip(Type, Value, Value).
95
96roundtrip(Type, Value, ExpectedValue) ->
97    asn1_test_lib:roundtrip('SeqDefault', Type, Value, ExpectedValue).
98