1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2001-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(testSeqSetDefaultVal).
22-export([main/2]).
23
24-include("External.hrl").
25-include_lib("common_test/include/ct.hrl").
26
27-record('SeqInts',{a = asn1_DEFAULT,
28		   b = asn1_DEFAULT,
29		   c = asn1_DEFAULT,
30		   d = asn1_DEFAULT}).
31-record('SetInts',{a = asn1_DEFAULT,
32		   b = asn1_DEFAULT,
33		   c = asn1_DEFAULT,
34		   d = asn1_DEFAULT}).
35-record('SeqBS',{a = asn1_DEFAULT,
36		 b = asn1_DEFAULT,
37		 c = asn1_DEFAULT,
38		 d = asn1_DEFAULT,
39		 e = asn1_DEFAULT}).
40-record('SeqBS2',{bs = asn1_DEFAULT}).
41-record('SetBS',{a = asn1_DEFAULT,
42		 b = asn1_DEFAULT,
43		 c = asn1_DEFAULT,
44		 d = asn1_DEFAULT}).
45-record('SeqOS',{a = asn1_DEFAULT,
46		 b = asn1_DEFAULT,
47		 c = asn1_DEFAULT}).
48-record('SetOS',{a = asn1_DEFAULT,
49		 b = asn1_DEFAULT,
50		 c = asn1_DEFAULT}).
51-record('SeqOI',{a = asn1_DEFAULT,
52		 b = asn1_DEFAULT,
53		 c = asn1_DEFAULT}).
54-record('SetOI',{a = asn1_DEFAULT,
55		 b = asn1_DEFAULT,
56		 c = asn1_DEFAULT}).
57-record('SeqEnum',{a = asn1_DEFAULT,
58		   b = asn1_DEFAULT}).
59-record('SetEnum',{a = asn1_DEFAULT,
60		   b = asn1_DEFAULT}).
61-record('SeqIntBool',{a = asn1_DEFAULT,
62		      b = asn1_DEFAULT,
63		      c = asn1_DEFAULT}).
64-record('SeqIntBool_a',{aa = asn1_DEFAULT,
65			ab = asn1_DEFAULT}).
66-record('SetIntBool',{a = asn1_DEFAULT,
67		      b = asn1_DEFAULT,
68		      c = asn1_DEFAULT}).
69-record('SetIntBool_a',{aa = asn1_DEFAULT,
70			ab = asn1_DEFAULT}).
71-record('SeqStrings',{a = asn1_DEFAULT,
72		      b1 = asn1_DEFAULT,
73		      b2 = asn1_DEFAULT,
74		      b3 = asn1_DEFAULT,
75		      c = asn1_DEFAULT,
76		      d = asn1_DEFAULT}).
77-record('SetStrings',{a = asn1_DEFAULT,
78		      b1 = asn1_DEFAULT,
79		      b2 = asn1_DEFAULT,
80		      b3 = asn1_DEFAULT,
81		      c = asn1_DEFAULT,
82		      d = asn1_DEFAULT}).
83-record('S1',{a = asn1_DEFAULT,
84	      b = asn1_DEFAULT}).
85-record('S1_a',{aa = asn1_DEFAULT,
86		ab = asn1_DEFAULT}).
87-record('S2',{a = asn1_DEFAULT, b=asn1_NOVALUE}).
88-record('S3',{a = asn1_DEFAULT,
89	      b = asn1_DEFAULT,
90	      c = asn1_DEFAULT,
91	      d = asn1_DEFAULT}).
92-record('S3set',{a = asn1_DEFAULT,
93		 b = asn1_DEFAULT}).
94-record('S4',{a = asn1_DEFAULT,
95	      b = asn1_DEFAULT}).
96-record('S4_b',{ba = asn1_DEFAULT,
97		bb = asn1_DEFAULT}).
98-record('SeqNamedInts',
99	{i1 = asn1_DEFAULT,
100	 i2 = asn1_DEFAULT}).
101-record('S5',{s3 = asn1_DEFAULT,
102	      so = asn1_DEFAULT,
103	      soe = asn1_DEFAULT}).
104-record('SOI', {soi = asn1_DEFAULT}).
105
106main(ber, []) ->
107    %% Nothing to test because plain BER will only use
108    %% default values when explicitly told to do so by
109    %% asn1_DEFAULT.
110    ok;
111main(Rule, Opts) ->
112    %% DER, PER, UPER. These encodings should not encode
113    %% values that are equal to the default value.
114
115    case {Rule,Opts} of
116	{ber,[der]} ->
117	    der(),
118	    case 'Default':legacy_erlang_types() of
119		false -> der_new_types();
120		true -> der_legacy()
121	    end;
122	{_,_} ->
123	    ok
124    end,
125
126    Ts = [{#'SeqInts'{},
127	   [{#'SeqInts'.c,
128	     [asn1_DEFAULT,
129	      three,
130	      3]}]},
131
132	  {#'SeqBS'{},
133	   [{#'SeqBS'.a,
134	     [asn1_DEFAULT,			%Always.
135	      <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>],
136	     [2#0110101,			%Legacy only.
137	      [1,0,1,0,1,1,0],
138	      {1,<<16#AC>>}]},
139	    {#'SeqBS'.b,
140	     [asn1_DEFAULT,
141	      <<16#A8:8,16#A:4>>],
142	     [2#10100010101,
143	      [1,0,1,0,1,0,0,0,1,0,1,0],
144	      {4,<<16#A8,16#A0>>}]},
145	    {#'SeqBS'.c,
146	     [asn1_DEFAULT,
147	      [second],
148	      <<1:2>>],
149	     [[0,1],
150	      {6,<<0:1,1:1,0:6>>}]},
151	    {#'SeqBS'.c,			%Zeroes on the right
152	     [asn1_DEFAULT,
153	      [second],
154	      <<1:2,0:17>>],
155	     [[0,1,0,0,0],
156	      {4,<<0:1,1:1,0:6>>}]},
157	    {#'SeqBS'.d,
158	     [asn1_DEFAULT,
159	      <<2#1001:4>>],
160	     [2#1001,
161	      [1,0,0,1],
162	      {4,<<2#1001:4,0:4>>}]},
163	    {#'SeqBS'.e,
164	     [asn1_DEFAULT,
165	      <<2#01011010:8>>],
166	     [[0,1,0,1,1,0,1,0],
167	      {0,<<2#01011010:8>>}]},
168	    %% Not EQUAL to DEFAULT.
169	    {#'SeqBS'.b,
170	     [<<6:3>>],
171	     [[1,1,0],				%Not equal to DEFAULT
172	      {5,<<6:3,0:5>>}]}
173	   ]},
174
175	  {#'SeqOS'{},
176	   [{#'SeqOS'.a,
177	     [asn1_DEFAULT,
178	      <<172>>]}]},
179
180	  {#'SeqOI'{},
181	   [{#'SeqOI'.a,
182	     [asn1_DEFAULT,
183	      {1,2,14,15}]},
184	    {#'SeqOI'.b,
185	     [asn1_DEFAULT,
186	      %%	      {iso,'member-body',250,3,4},
187	      {1,2,250,3,4}]},
188	    {#'SeqOI'.c,
189	     [asn1_DEFAULT,
190	      %%	      {iso,standard,8571,2,250,4},
191	      {1,0,8571,2,250,4}]}]}
192	 ],
193    R0 = [[consistency(Rec, PosVs) || PosVs <- Fs] || {Rec,Fs} <- Ts],
194    case lists:flatten(R0) of
195	[] ->
196	    ok;
197	[_|_]=R ->
198	    ct:fail("~p\n", [R])
199    end.
200
201legacy_filter({_,_}=Keep) ->
202    Keep;
203legacy_filter({Rec,Standard,Legacy}) ->
204    case 'Default':legacy_erlang_types() of
205	false ->
206	    {Rec,Standard};
207	true ->
208	    {Rec,Standard++Legacy}
209    end.
210
211consistency(Rec0, PosVs) ->
212    {Pos,[V|Vs]=AllVs} = legacy_filter(PosVs),
213    T = element(1, Rec0),
214    io:format("~p: ~p\n", [T,AllVs]),
215    Rec = setelement(Pos, Rec0, V),
216    {ok,Enc} = 'Default':encode(T, Rec),
217    {ok,_SmokeTest} = 'Default':decode(T, Enc),
218    consistency_1(Vs, Rec0, Pos, Enc).
219
220consistency_1([V|Vs], Rec0, Pos, Enc) ->
221    Rec = setelement(Pos, Rec0, V),
222    case 'Default':encode(element(1, Rec), Rec) of
223	{ok,Enc} ->
224	    consistency_1(Vs, Rec0, Pos, Enc);
225	{ok,WrongEnc} ->
226	    [{Rec,{wrong,WrongEnc},{should_be,Enc}}|
227	     consistency_1(Vs, Rec0, Pos, Enc)]
228    end;
229consistency_1([], _, _, _) -> [].
230
231der() ->
232    io:put_chars("Performing DER-specific tests..."),
233    roundtrip(<<48,0>>,
234	      'SeqInts',
235	      #'SeqInts'{a=asn1_DEFAULT,b=asn1_DEFAULT,
236			 c=asn1_DEFAULT,d=asn1_DEFAULT},
237	      #'SeqInts'{a=1,b=-1,c=3,d=1}),
238    roundtrip(<<48,0>>,
239	      'SeqInts',
240	      #'SeqInts'{a=1,b=-1,c=three,d=1},
241	      #'SeqInts'{a=1,b=-1,c=3,d=1}),
242
243    roundtrip(<<49,0>>,
244	      'SetInts',
245	      #'SetInts'{a=asn1_DEFAULT,b=asn1_DEFAULT,
246			 c=asn1_DEFAULT,d=asn1_DEFAULT},
247	      #'SetInts'{a=1,b=-1,c=3,d=1}),
248    roundtrip(<<49,0>>,
249	      'SetInts',
250	      #'SetInts'{a=1,b=-1,c=three,d=1},
251	      #'SetInts'{a=1,b=-1,c=3,d=1}),
252
253    roundtrip(<<48,0>>,
254	      'SeqOI',
255	      #'SeqOI'{a={1,2,14,15},
256		       b={iso,'member-body',250,3,4},
257		       c={iso,standard,8571,2,250,4}},
258	      #'SeqOI'{a={1,2,14,15},
259		       b={1,2,250,3,4},
260		       c={1,0,8571,2,250,4}}),
261
262    roundtrip(<<49,0>>,
263	      'SetOI',
264	      #'SetOI'{a={1,2,14,15},
265		       b={iso,'member-body',250,3,4},
266		       c={iso,standard,8571,2,250,4}},
267	      #'SetOI'{a={1,2,14,15},
268		       b={1,2,250,3,4},
269		       c={1,0,8571,2,250,4}}),
270
271    roundtrip(<<48,0>>, 'SeqEnum', #'SeqEnum'{a=b4,b=b2}),
272    roundtrip(<<49,0>>, 'SetEnum', #'SetEnum'{a=b4,b=b2}),
273
274    roundtrip(<<48,0>>,
275	      'SeqIntBool',
276	      #'SeqIntBool'{a=#'SeqIntBool_a'{aa=12,ab=13},
277			    b=#'S2'{a=14,b=true},
278			    c=#'S2'{a=15,b=false}}),
279    roundtrip(<<48,0>>,
280	      'SeqIntBool',
281	      #'SeqIntBool'{a=asn1_DEFAULT,b=asn1_DEFAULT,c=asn1_DEFAULT},
282	      #'SeqIntBool'{a=#'SeqIntBool_a'{aa=12,ab=13},
283			    b=#'S2'{a=14,b=true},
284			    c=#'S2'{a=15,b=false}}),
285
286    roundtrip(<<49,0>>,
287	      'SetIntBool',
288	      #'SetIntBool'{a=#'SetIntBool_a'{aa=12,ab=13},
289			    b=#'S2'{a=14,b=true},
290			    c=#'S2'{a=15,b=false}}),
291    roundtrip(<<49,0>>,
292	      'SetIntBool',
293	      #'SetIntBool'{a=asn1_DEFAULT,b=asn1_DEFAULT,c=asn1_DEFAULT},
294	      #'SetIntBool'{a=#'SetIntBool_a'{aa=12,ab=13},
295			    b=#'S2'{a=14,b=true},
296			    c=#'S2'{a=15,b=false}}),
297
298    roundtrip(<<48,0>>,
299	      'SeqStrings',
300	      #'SeqStrings'{a="123456789",b1="abcdef",
301			    b2={0,13},
302			    b3={"First line",{0,13},"Second line"},
303			    c="Printable string",
304			    d={0,0,1,14}},
305	      #'SeqStrings'{a="123456789",b1="abcdef",
306			    b2=[0,13],
307			    b3=["First line",[0,13],"Second line"],
308			    c="Printable string",
309			    d=[0,0,1,14]}),
310
311    roundtrip(<<49,0>>,
312	      'SetStrings',
313	      #'SetStrings'{a="123456789",b1="abcdef",
314			    b2={0,13},
315			    b3={"First line",{0,13},"Second line"},
316			    c="Printable string",
317			    d={0,0,1,14}},
318	      #'SetStrings'{a="123456789",b1="abcdef",
319			    b2=[0,13],
320			    b3=["First line",[0,13],"Second line"],
321			    c="Printable string",
322			    d=[0,0,1,14]}),
323
324    roundtrip(<<48,0>>,
325	      'S1',
326	      #'S1'{a=#'S1_a'{aa=1,ab=#'S2'{a=2,b=true}},
327		    b=#'S4'{a=#'S2'{a=2,b=true},b=#'S4_b'{ba=true,bb=5}}}),
328
329    roundtrip(<<48,3,129,1,255>>, 'S2', #'S2'{a=1,b=true}),
330
331    roundtrip(<<48,0>>,
332	      'S3',
333	      #'S3'{a="\v\f\r",
334		    b=[{a,11},{b,true},{c,13}],
335		    c=[1,2,3,4],
336		    d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}),
337    roundtrip(<<48,0>>,
338	      'S3',
339	      #'S3'{a=[11,13,12],
340		    b=[{b,true},{a,11},{c,13}],
341		    c=[3,4,1,2],
342		    d=[#'S2'{a=30,b=false},#'S2'{a=20,b=true}]},
343	      #'S3'{a=[11,12,13],
344		    b=[{a,11},{b,true},{c,13}],
345		    c=[1,2,3,4],
346		    d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}),
347    roundtrip(<<48,0>>,
348	      'S3',
349	      #'S3'{a=asn1_DEFAULT,b=asn1_DEFAULT,
350		    c=asn1_DEFAULT,d=asn1_DEFAULT},
351	      #'S3'{a=[11,12,13],
352		    b=[{a,11},{b,true},{c,13}],
353		    c=[1,2,3,4],
354		    d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}),
355
356    roundtrip(<<49,0>>,
357	      'S3set',
358	      #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}],
359		       b=[1,2,3,4]}),
360    roundtrip(<<49,0>>,
361	      'S3set',
362	      #'S3set'{a=[{b,17},{c,#'S2'{a=3,b=true}},{a,false}],
363		       b=[1,3,4,2]},
364	      #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}],
365		       b=[1,2,3,4]}),
366    roundtrip(<<49,0>>,
367	      'S3set',
368	      #'S3set'{a=asn1_DEFAULT,b=asn1_DEFAULT},
369	      #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}],
370		       b=[1,2,3,4]}),
371
372    roundtrip(<<48,0>>,
373	      'S4',
374	      #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}},
375	      #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}}),
376
377    roundtrip(<<48,0>>,
378	      'SeqBS',
379	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
380		       c=[second], d = <<2#1001:4>>,
381		       e = <<2#01011010:8>>}),
382    roundtrip(<<49,0>>,
383	      'SetBS',
384	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
385		       c=[second], d = <<2#1001:4>>}),
386
387    %% None of the default values are used.
388    roundtrip(<<48,19,128,2,7,128,129,2,5,64,130,2,5,32,131,1,0,132,2,5,224>>,
389	      'SeqBS',
390	      #'SeqBS'{a = <<1:1>>,
391		       b = <<2:3>>,
392		       c = [third],
393		       d = <<>>,
394		       e = <<7:3>>}),
395    roundtrip(<<49,3,131,1,0>>,
396	      'SetBS',
397	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
398		       c=[second], d = <<>>}),
399
400    %% SeqNamedInts
401    roundtrip(<<48,0>>,
402	      'SeqNamedInts',
403	      #'SeqNamedInts'{i1=15,i2=31}),
404    roundtrip(<<48,0>>,
405	      'SeqNamedInts',
406	      #'SeqNamedInts'{},
407	      #'SeqNamedInts'{i1=15,i2=31}),
408    roundtrip(<<48,0>>,
409	      'SeqNamedInts',
410	      #'SeqNamedInts'{i2=last},
411	      #'SeqNamedInts'{i1=15,i2=31}),
412    roundtrip(<<48,3,128,1,0>>,
413	      'SeqNamedInts',
414	      #'SeqNamedInts'{i1=first,i2=31},
415	      #'SeqNamedInts'{i1=first,i2=31}),
416
417    %% S5
418    roundtrip(<<48,0>>,
419	      'S5',
420	      #'S5'{s3=#'S3'{a=[11,12,13],
421			     b=[{a,11},{b,true},{c,13}],
422			     c=[1,2,3,4],
423			     d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]},
424		    so=[{0,1,999},{0,1,555}],
425		    soe=[]}),
426    roundtrip(<<48,0>>,
427	      'S5',
428	      #'S5'{},
429	      #'S5'{s3=#'S3'{a=[11,12,13],
430			     b=[{a,11},{b,true},{c,13}],
431			     c=[1,2,3,4],
432			     d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]},
433		    so=[{0,1,999},{0,1,555}],
434		    soe=[]}),
435
436    %% SOI
437    roundtrip(<<48,0>>,
438	      'SOI',
439	      #'SOI'{},
440	      #'SOI'{soi=[{1,2,250,9,55},{1,2,250,3,4}]}),
441
442    %% SeqBS2
443    roundtrip(<<48,0>>,
444	      'SeqBS2',
445	      #'SeqBS2'{bs= <<16#5:3>>}),
446    roundtrip(<<48,0>>,
447	      'SeqBS2',
448	      #'SeqBS2'{bs= <<16#5:3,0:4>>},
449	      #'SeqBS2'{bs= <<16#5:3>>}),
450
451    ok.
452
453der_new_types() ->
454    io:put_chars("Performing DER-specific tests with new types..."),
455
456    roundtrip(<<48,0>>, 'SeqOS',
457	      #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
458
459    roundtrip(<<49,0>>, 'SetOS',
460	      #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
461    ok.
462
463der_legacy() ->
464    io:put_chars("Performing DER-specific tests with legacy types..."),
465
466    roundtrip(<<48,0>>, 'SeqOS',
467	      #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}),
468    roundtrip(<<49,0>>, 'SetOS',
469	      #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}),
470
471    roundtrip(<<48,0>>,
472	      'SeqBS',
473	      #'SeqBS'{a=2#0110101,
474		       b=2#010100010101,
475		       c=[second],
476		       d=[1,0,0,1]},
477	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
478		       c=[second], d = <<2#1001:4>>,
479		       e = <<2#01011010:8>>}),
480    roundtrip(<<48,0>>,
481	      'SeqBS',
482	      #'SeqBS'{a=[1,0,1,0,1,1,0],
483		       b=[1,0,1,0,1,0,0,0,1,0,1,0],
484		       c={5,<<64>>},
485		       d=2#1001},
486	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
487		       c=[second], d = <<2#1001:4>>,
488		       e = <<2#01011010:8>>}),
489    roundtrip(<<48,3,131,1,0>>,
490	      'SeqBS',
491	      #'SeqBS'{a=[1,0,1,0,1,1,0],
492		       b=[1,0,1,0,1,0,0,0,1,0,1,0],
493		       c={5,<<64>>},
494		       d=0},
495	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
496		       c=[second], d = <<>>,
497		       e = <<2#01011010:8>>}),
498    roundtrip(<<48,3,131,1,0>>,
499	      'SeqBS',
500	      #'SeqBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>,
501		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>,
502		       c = <<2:3>>,
503		       d=0,
504		       e = <<16#5A:8>>},
505	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
506		       c=[second], d = <<>>,
507		       e = <<2#01011010:8>>}),
508
509    %% None of the default values are used.
510    roundtrip(<<48,19,128,2,7,128,129,2,5,64,130,2,5,32,131,1,0,132,2,5,224>>,
511	      'SeqBS',
512	      #'SeqBS'{a = <<1:1>>,
513		       b = {5,<<64>>},
514		       c = [third],
515		       d = 0,
516		       e = <<7:3>>},
517	      #'SeqBS'{a = <<1:1>>,
518		       b = <<2:3>>,
519		       c = [third],
520		       d = <<>>,
521		       e = <<7:3>>}),
522    roundtrip(<<49,0>>,
523	      'SetBS',
524	      #'SetBS'{a=2#0110101,
525		       b=2#010100010101,
526		       c=[second],
527		       d=[1,0,0,1]},
528	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
529		       c=[second], d = <<2#1001:4>>}),
530    roundtrip(<<49,0>>,
531	      'SetBS',
532	      #'SetBS'{a=[1,0,1,0,1,1,0],
533		       b=[1,0,1,0,1,0,0,0,1,0,1,0],
534		       c={5,<<64>>},
535		       d=9},
536	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
537		       c=[second], d = <<2#1001:4>>}),
538    roundtrip(<<49,3,131,1,0>>,
539	      'SetBS',
540	      #'SetBS'{a=[1,0,1,0,1,1,0],
541		       b=[1,0,1,0,1,0,0,0,1,0,1,0],
542		       c={5,<<64>>},
543		       d=0},
544	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
545		       c=[second], d = <<>>}),
546    roundtrip(<<49,3,131,1,0>>,
547	      'SetBS',
548	      #'SetBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>,
549		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>,
550		       c = <<2:3>>,
551		       d=0},
552	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>,
553		       c=[second], d = <<>>}),
554
555    ok.
556
557roundtrip(Encoded, Type, Value) ->
558    roundtrip(Encoded, Type, Value, Value).
559
560roundtrip(Encoded, Type, Value, ExpectedValue) ->
561    Encoded = asn1_test_lib:roundtrip_enc('Default', Type,
562					  Value, ExpectedValue),
563    ok.
564