4
%% Copyright Ericsson AB 2003-2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
-module(testINSTANCE_OF).
22
-export([compile/3,main/1]).
24
-include_lib("test_server/include/test_server.hrl").
27
compile(Config,Rules,Opt) ->
29
?line DataDir = ?config(data_dir,Config),
30
?line OutDir = ?config(priv_dir,Config),
31
?line true = code:add_patha(?config(priv_dir,Config)),
33
?line ok = asn1ct:compile(DataDir ++ "INSTANCEOF.asn1",
34
[Rules,{outdir,OutDir}]++Opt).
39
?line {ok,Integer} = asn1_wrapper:encode('INSTANCEOF','Int',3),
40
Int = wrap(Erule,Integer),
41
ValotherName = {otherName,{'INSTANCE OF',{2,4},Int}},
42
VallastName1 = {lastName,{'GeneralName_lastName',{2,4},12}},
43
VallastName2 = {lastName,{'GeneralName_lastName',{2,3,4},
46
asn1_wrapper:encode('INSTANCEOF','GeneralName',ValotherName),
47
?line {ok,Res1={otherName,_}} =
48
asn1_wrapper:decode('INSTANCEOF','GeneralName',BytesoN),
49
?line ok = test_encdec(Erule,Int,Res1),
52
asn1_wrapper:encode('INSTANCEOF','GeneralName',VallastName1),
53
?line {ok,Res2={lastName,_}} =
54
asn1_wrapper:decode('INSTANCEOF','GeneralName',ByteslN1),
55
?line test_encdec(Erule,Res2),
58
asn1_wrapper:encode('INSTANCEOF','GeneralName',VallastName2),
59
?line {ok,Res3={lastName,_}} =
60
asn1_wrapper:decode('INSTANCEOF','GeneralName',ByteslN2),
61
?line test_encdec(Erule,Res3).
63
test_encdec(_Erule,Int,{otherName,{'INSTANCE OF',{2,4},Int}}) ->
65
test_encdec(Erule,Int,R={otherName,{'INSTANCE OF',{2,4},_Int2}}) ->
66
{error,{Erule,Int,R}}.
68
test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,4},12}}) ->
70
test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,3,4},
73
test_encdec(Erule,Res) ->
76
wrap(ber,Int) when is_list(Int) ->
77
binary_to_list(list_to_binary(Int));
78
wrap(per,Int) when is_list(Int) ->
79
binary_to_list(list_to_binary(Int));
80
wrap(ber_bin,Int) when is_list(Int) ->
82
wrap(ber_bin_v2,Int) when is_list(Int) ->
84
wrap(per_bin,Int) when is_list(Int) ->
86
wrap(uper_bin,Int) when is_list(Int) ->