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(testSetOptional). 22 23-include("External.hrl"). 24-export([main/1]). 25-export([ticket_7533/1]). 26 27-record('SetOpt1',{bool1 = asn1_NOVALUE, int1, set1 = asn1_NOVALUE}). 28-record('SetOpt1Imp',{bool1 = asn1_NOVALUE, int1, set1 = asn1_NOVALUE}). 29-record('SetOpt1Exp',{bool1 = asn1_NOVALUE, int1, set1 = asn1_NOVALUE}). 30-record('SetOpt2',{set2 = asn1_NOVALUE, bool2, int2}). 31-record('SetOpt2Imp',{set2 = asn1_NOVALUE, bool2, int2}). 32-record('SetOpt2Exp',{set2 = asn1_NOVALUE, bool2, int2}). 33-record('SetOpt3',{bool3 = asn1_NOVALUE, set3 = asn1_NOVALUE, int3 = asn1_NOVALUE}). 34-record('SetOpt3Imp',{bool3 = asn1_NOVALUE, set3 = asn1_NOVALUE, int3 = asn1_NOVALUE}). 35-record('SetOpt3Exp',{bool3 = asn1_NOVALUE, set3 = asn1_NOVALUE, int3 = asn1_NOVALUE}). 36-record('SetIn',{boolIn, intIn}). 37 38main(_Rules) -> 39 roundtrip('SetOpt1', 40 #'SetOpt1'{bool1=true,int1=15, 41 set1=#'SetIn'{boolIn=true,intIn=66}}), 42 roundtrip('SetOpt1', #'SetOpt1'{int1=15}), 43 44 roundtrip('SetOpt2', #'SetOpt2'{bool2=true,int2=15, 45 set2=#'SetIn'{boolIn=true,intIn=66}}), 46 roundtrip('SetOpt2', #'SetOpt2'{int2=15,bool2=true}), 47 48 roundtrip('SetOpt3', #'SetOpt3'{bool3=true,int3=15, 49 set3=#'SetIn'{boolIn=true,intIn=66}}), 50 roundtrip('SetOpt3', #'SetOpt3'{int3=15}), 51 52 roundtrip('SetOpt1Imp', 53 #'SetOpt1Imp'{bool1=true,int1 = 15, 54 set1=#'SetIn'{boolIn = true,intIn = 66}}), 55 roundtrip('SetOpt1Imp', #'SetOpt1Imp'{int1=15}), 56 57 58 roundtrip('SetOpt2Imp', 59 #'SetOpt2Imp'{bool2=true,int2=15, 60 set2=#'SetIn'{boolIn=true,intIn=66}}), 61 roundtrip('SetOpt2Imp',#'SetOpt2Imp'{int2=15,bool2=true}), 62 63 64 roundtrip('SetOpt3Imp', 65 #'SetOpt3Imp'{bool3=true,int3=15, 66 set3=#'SetIn'{boolIn=true,intIn=66}}), 67 roundtrip('SetOpt3Imp', #'SetOpt3Imp'{int3=15}), 68 69 roundtrip('SetOpt1Exp', 70 #'SetOpt1Exp'{bool1=true,int1=15, 71 set1=#'SetIn'{boolIn=true,intIn=66}}), 72 roundtrip('SetOpt1Exp', #'SetOpt1Exp'{int1=15}), 73 74 roundtrip('SetOpt2Exp', 75 #'SetOpt2Exp'{bool2=true,int2=15, 76 set2=#'SetIn'{boolIn=true,intIn=66}}), 77 roundtrip('SetOpt2Exp', #'SetOpt2Exp'{int2=15,bool2=true}), 78 79 roundtrip('SetOpt3Exp', 80 #'SetOpt3Exp'{bool3=true,int3=15, 81 set3=#'SetIn'{boolIn=true,intIn=66}}), 82 roundtrip('SetOpt3Exp', #'SetOpt3Exp'{int3=15}), 83 84 ok. 85 86 87ticket_7533(Ber) when Ber == ber -> 88 Val = #'SetOpt1'{bool1=true,int1=12,set1=#'SetIn'{boolIn=false,intIn=13}}, 89 roundtrip('SetOpt1', Val), 90 CorruptVal = <<49,14,1,1,255,2,1,12,0:8/unit:8>>, 91 {error,_} = 'SetOptional':decode('SetOpt1', CorruptVal), 92 ok; 93ticket_7533(_) -> 94 ok. 95 96roundtrip(Type, Value) -> 97 asn1_test_lib:roundtrip('SetOptional', Type, Value). 98