~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/asn1/test/testParamBasic.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2010-03-09 17:34:57 UTC
  • mfrom: (10.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100309173457-4yd6hlcb2osfhx31
Tags: 1:13.b.4-dfsg-3
Manpages in section 1 are needed even if only arch-dependent packages are
built. So, re-enabled them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
 
5
%% 
 
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/.
 
11
%% 
 
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
 
15
%% under the License.
 
16
%% 
 
17
%% %CopyrightEnd%
 
18
%%
 
19
%%
 
20
-module(testParamBasic).
 
21
 
 
22
-export([compile/3]).
 
23
-export([compile_der/2]).
 
24
-export([main/1]).
 
25
 
 
26
-include("test_server.hrl").
 
27
 
 
28
-record('T11',{number, string=asn1_DEFAULT}).
 
29
-record('T12',{number, string=asn1_DEFAULT}).
 
30
-record('T21',{number, string}).
 
31
-record('T22',{number, string}).
 
32
 
 
33
 
 
34
compile(Config,Rules,Options) ->
 
35
 
 
36
    ?line DataDir = ?config(data_dir,Config),
 
37
    ?line OutDir = ?config(priv_dir,Config),
 
38
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
39
    ?line ok = asn1ct:compile(DataDir ++ "ParamBasic",
 
40
                              [Rules,{outdir,OutDir}]++Options).
 
41
 
 
42
compile_der(Config,Rules) ->
 
43
    ?line DataDir = ?config(data_dir,Config),
 
44
    ?line OutDir = ?config(priv_dir,Config),
 
45
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
46
    ?line ok = asn1ct:compile(DataDir ++ "ParamBasic",
 
47
                              [der,Rules,{outdir,OutDir}]).
 
48
 
 
49
main(Rules) ->
 
50
    
 
51
    ?line {ok,Bytes11} = 
 
52
        asn1_wrapper:encode('ParamBasic','T11',
 
53
                            #'T11'{number = 11,
 
54
                                   string = "hello"}),
 
55
    ?line {ok,{'T11',11,"hello"}} =
 
56
        asn1_wrapper:decode('ParamBasic','T11',Bytes11),
 
57
            
 
58
    ?line {ok,Bytes12} = 
 
59
        asn1_wrapper:encode('ParamBasic','T12',
 
60
                            #'T12'{number = 11,
 
61
                                   string = [1,0,1,0,1]}),
 
62
    ?line {ok,{'T12',11,[1,0,1,0,1]}} =
 
63
        asn1_wrapper:decode('ParamBasic','T12',Bytes12),
 
64
    
 
65
    ?line {ok,Bytes13} = 
 
66
        asn1_wrapper:encode('ParamBasic','T21',
 
67
                            #'T21'{number = 11,
 
68
                                   string = "hello"}),
 
69
    ?line {ok,{'T21',11,"hello"}} =
 
70
        asn1_wrapper:decode('ParamBasic','T21',Bytes13),
 
71
            
 
72
    ?line {ok,Bytes14} = 
 
73
        asn1_wrapper:encode('ParamBasic','T22',
 
74
                            #'T22'{number = 11,
 
75
                                   string = [1,0,1,0,1]}),
 
76
    ?line {ok,{'T22',11,[1,0,1,0,1]}} =
 
77
        asn1_wrapper:decode('ParamBasic','T22',Bytes14),
 
78
 
 
79
    case Rules of
 
80
        der ->
 
81
 
 
82
            ?line {ok,[48,3,128,1,11]} = 
 
83
                asn1_wrapper:encode('ParamBasic','T11',
 
84
                                    #'T11'{number = 11,
 
85
                                           string = "hej"}),
 
86
            ?line {ok,{'T11',11,"hej"}} =
 
87
                asn1_wrapper:decode('ParamBasic','T11',[48,3,128,1,11]),
 
88
            
 
89
            ?line {ok,[48,3,128,1,11]} = 
 
90
                asn1_wrapper:encode('ParamBasic','T12',
 
91
                                    #'T12'{number = 11,
 
92
                                           string = [1,0,1,0]}),
 
93
            
 
94
            ?line {ok,{'T12',11,[1,0,1,0]}} =
 
95
                asn1_wrapper:decode('ParamBasic','T12',[48,3,128,1,11]);
 
96
        _ -> ok
 
97
    end,
 
98
            
 
99
    ok.