~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%%
 
4
%% Copyright Ericsson AB 1997-2010. 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(testPrim).
 
21
 
 
22
-export([compile/3]).
 
23
-export([bool/1]).
 
24
-export([int/1]).
 
25
-export([enum/1]).
 
26
-export([obj_id/1]).
 
27
-export([rel_oid/1]).
 
28
-export([null/1]).
 
29
-export([real/1]).
 
30
 
 
31
-include_lib("test_server/include/test_server.hrl").
 
32
 
 
33
 
 
34
 
 
35
compile(Config,Rules,Opt) ->
 
36
 
 
37
    ?line DataDir = ?config(data_dir,Config),
 
38
    ?line OutDir = ?config(priv_dir,Config),
 
39
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
40
    case Opt of
 
41
        [optimize] ->
 
42
            ?line ok = asn1ct:compile(DataDir ++ "Prim",
 
43
                                      [Rules,optimize,{outdir,OutDir}]),
 
44
            ?line ok = asn1ct:compile(DataDir ++ "Real",
 
45
                                      [Rules,optimize,{outdir,OutDir}]);
 
46
        __ ->
 
47
            ?line ok = asn1ct:compile(DataDir ++ "Prim",
 
48
                                      [Rules,{outdir,OutDir}]),
 
49
            ?line ok = asn1ct:compile(DataDir ++ "Real",
 
50
                                      [Rules,{outdir,OutDir}])
 
51
    end.
 
52
 
 
53
 
 
54
 
 
55
 
 
56
bool(Rules) ->
 
57
 
 
58
    %%==========================================================
 
59
    %% Bool ::=  BOOLEAN 
 
60
    %%==========================================================
 
61
 
 
62
    ?line {ok,Bytes1} = asn1_wrapper:encode('Prim','Bool',true),
 
63
    ?line {ok,true} = asn1_wrapper:decode('Prim','Bool',lists:flatten(Bytes1)),
 
64
 
 
65
    ?line {ok,Bytes2} = asn1_wrapper:encode('Prim','Bool',false),
 
66
    ?line {ok,false} = asn1_wrapper:decode('Prim','Bool',lists:flatten(Bytes2)),
 
67
 
 
68
    ?line case asn1_wrapper:erule(Rules) of
 
69
              ber -> 
 
70
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
71
                      (catch asn1_wrapper:encode('Prim','Bool',517)),
 
72
                  ok;
 
73
              per ->
 
74
                  ok
 
75
          end,
 
76
 
 
77
    
 
78
 
 
79
 
 
80
 
 
81
    %%==========================================================
 
82
    %% BoolCon ::=  [20] BOOLEAN 
 
83
    %%==========================================================
 
84
 
 
85
 
 
86
    ?line {ok,BytesCon1} = asn1_wrapper:encode('Prim','BoolCon',true),
 
87
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolCon',lists:flatten(BytesCon1)),
 
88
 
 
89
    ?line {ok,BytesCon2} = asn1_wrapper:encode('Prim','BoolCon',false),
 
90
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolCon',lists:flatten(BytesCon2)),
 
91
 
 
92
    ?line case asn1_wrapper:erule(Rules) of
 
93
              ber -> 
 
94
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
95
                      (catch asn1_wrapper:encode('Prim','BoolCon',517)),
 
96
                  ok;
 
97
              per ->
 
98
                  ok
 
99
          end,
 
100
    
 
101
 
 
102
 
 
103
 
 
104
 
 
105
    %%==========================================================
 
106
    %% BoolPri ::=  [PRIVATE 21] BOOLEAN 
 
107
    %%==========================================================
 
108
 
 
109
    ?line {ok,BytesPri1} = asn1_wrapper:encode('Prim','BoolPri',true),
 
110
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolPri',lists:flatten(BytesPri1)),
 
111
 
 
112
    ?line {ok,BytesPri2} = asn1_wrapper:encode('Prim','BoolPri',false),
 
113
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolPri',lists:flatten(BytesPri2)),
 
114
 
 
115
    ?line case asn1_wrapper:erule(Rules) of
 
116
              ber -> 
 
117
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
118
                      (catch asn1_wrapper:encode('Prim','BoolPri',517)),
 
119
                  ok;
 
120
              per ->
 
121
                  ok
 
122
          end,
 
123
 
 
124
 
 
125
    %%==========================================================
 
126
    %% BoolApp ::=  [APPLICATION 22] BOOLEAN 
 
127
    %%==========================================================
 
128
 
 
129
    ?line {ok,BytesApp1} = asn1_wrapper:encode('Prim','BoolApp',true),
 
130
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolApp',lists:flatten(BytesApp1)),
 
131
 
 
132
    ?line {ok,BytesApp2} = asn1_wrapper:encode('Prim','BoolApp',false),
 
133
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolApp',lists:flatten(BytesApp2)),
 
134
 
 
135
    ?line case asn1_wrapper:erule(Rules) of
 
136
              ber -> 
 
137
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
138
                      (catch asn1_wrapper:encode('Prim','BoolApp',517)),
 
139
                  ok;
 
140
              per ->
 
141
                  ok
 
142
          end,
 
143
 
 
144
 
 
145
    %%==========================================================
 
146
    %% BoolExpCon ::=  [30] EXPLICIT BOOLEAN 
 
147
    %%==========================================================
 
148
 
 
149
    ?line {ok,BytesExpCon1} = asn1_wrapper:encode('Prim','BoolExpCon',true),
 
150
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolExpCon',lists:flatten(BytesExpCon1)),
 
151
 
 
152
    ?line {ok,BytesExpCon2} = asn1_wrapper:encode('Prim','BoolExpCon',false),
 
153
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolExpCon',lists:flatten(BytesExpCon2)),
 
154
 
 
155
    ?line case asn1_wrapper:erule(Rules) of
 
156
              ber -> 
 
157
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
158
                      (catch asn1_wrapper:encode('Prim','BoolExpCon',517)),
 
159
                  ok;
 
160
              per ->
 
161
                  ok
 
162
          end,
 
163
 
 
164
 
 
165
 
 
166
    %%==========================================================
 
167
    %% BoolExpPri ::=  [PRIVATE 31] EXPLICIT BOOLEAN 
 
168
    %%==========================================================
 
169
 
 
170
    ?line {ok,BytesExpPri1} = asn1_wrapper:encode('Prim','BoolExpPri',true),
 
171
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolExpPri',lists:flatten(BytesExpPri1)),
 
172
 
 
173
    ?line {ok,BytesExpPri2} = asn1_wrapper:encode('Prim','BoolExpPri',false),
 
174
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolExpPri',lists:flatten(BytesExpPri2)),
 
175
 
 
176
    ?line case asn1_wrapper:erule(Rules) of
 
177
              ber -> 
 
178
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
179
                      (catch asn1_wrapper:encode('Prim','BoolExpPri',517)),
 
180
                  ok;
 
181
              per ->
 
182
                  ok
 
183
          end,
 
184
 
 
185
 
 
186
    %%==========================================================
 
187
    %% BoolExpApp ::=  [APPLICATION 32] EXPLICIT BOOLEAN 
 
188
    %%==========================================================
 
189
 
 
190
    ?line {ok,BytesExpApp1} = asn1_wrapper:encode('Prim','BoolExpApp',true),
 
191
    ?line {ok,true} = asn1_wrapper:decode('Prim','BoolExpApp',lists:flatten(BytesExpApp1)),
 
192
 
 
193
    ?line {ok,BytesExpApp2} = asn1_wrapper:encode('Prim','BoolExpApp',false),
 
194
    ?line {ok,false} = asn1_wrapper:decode('Prim','BoolExpApp',lists:flatten(BytesExpApp2)),
 
195
 
 
196
    ?line case asn1_wrapper:erule(Rules) of
 
197
              ber -> 
 
198
                  ?line {error,{asn1,{encode_boolean,517}}} = 
 
199
                      (catch asn1_wrapper:encode('Prim','BoolExpApp',517)),
 
200
                  ok;
 
201
              per ->
 
202
                  ok
 
203
          end,
 
204
 
 
205
    ok.
 
206
 
 
207
 
 
208
int(Rules) ->
 
209
 
 
210
 
 
211
    %%==========================================================
 
212
    %% Int ::=  INTEGER 
 
213
    %%==========================================================
 
214
 
 
215
    %% test of OTP-2666 encoding should use minimum number of octets x.690 8.3.2
 
216
    ?line {ok,Bytes0} = asn1_wrapper:encode('Prim','Int',-128),
 
217
    ?line L0 = lists:flatten(Bytes0),
 
218
    ?line {ok,-128} = asn1_wrapper:decode('Prim','Int',lists:flatten(L0)),
 
219
    case asn1_wrapper:erule(Rules) of
 
220
        ber ->
 
221
            ?line [_,1,128] = L0;
 
222
        per -> ok
 
223
    end,
 
224
 
 
225
    ?line {ok,Bytes1} = asn1_wrapper:encode('Prim','Int',4),
 
226
    ?line {ok,4} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes1)),
 
227
 
 
228
    ?line {ok,Bytes2} = asn1_wrapper:encode('Prim','Int',444),
 
229
    ?line {ok,444} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes2)),
 
230
 
 
231
    ?line {ok,Bytes3} = asn1_wrapper:encode('Prim','Int',123456789),
 
232
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes3)),
 
233
 
 
234
    ?line {ok,Bytes4} = asn1_wrapper:encode('Prim','Int',12345678901234567890),
 
235
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes4)),
 
236
 
 
237
    ?line {ok,Bytes5} = asn1_wrapper:encode('Prim','Int',-100),
 
238
    ?line {ok,-100} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes5)),
 
239
 
 
240
    ?line {ok,Bytes6} = asn1_wrapper:encode('Prim','Int',-255),
 
241
    ?line {ok,-255} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes6)),
 
242
 
 
243
    ?line {ok,Bytes7} = asn1_wrapper:encode('Prim','Int',-256),
 
244
    ?line {ok,-256} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes7)),
 
245
 
 
246
    ?line {ok,Bytes8} = asn1_wrapper:encode('Prim','Int',-257),
 
247
    ?line {ok,-257} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes8)),
 
248
 
 
249
    ?line {ok,Bytes9} = asn1_wrapper:encode('Prim','Int',-1234567890),
 
250
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes9)),
 
251
 
 
252
    ?line {ok,Bytes10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
253
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(Bytes10)),
 
254
 
 
255
 
 
256
 
 
257
 
 
258
 
 
259
    %%==========================================================
 
260
    %% IntCon ::=  [40] INTEGER 
 
261
    %%==========================================================
 
262
 
 
263
    ?line {ok,BytesCon1} = asn1_wrapper:encode('Prim','IntCon',4),
 
264
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon1)),
 
265
 
 
266
    ?line {ok,BytesCon2} = asn1_wrapper:encode('Prim','IntCon',444),
 
267
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon2)),
 
268
 
 
269
    ?line {ok,BytesCon3} = asn1_wrapper:encode('Prim','IntCon',123456789),
 
270
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon3)),
 
271
 
 
272
    ?line {ok,BytesCon4} = asn1_wrapper:encode('Prim','IntCon',12345678901234567890),
 
273
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon4)),
 
274
 
 
275
    ?line {ok,BytesCon5} = asn1_wrapper:encode('Prim','IntCon',-100),
 
276
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon5)),
 
277
 
 
278
    ?line {ok,BytesCon6} = asn1_wrapper:encode('Prim','IntCon',-255),
 
279
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon6)),
 
280
 
 
281
    ?line {ok,BytesCon7} = asn1_wrapper:encode('Prim','IntCon',-256),
 
282
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon7)),
 
283
 
 
284
    ?line {ok,BytesCon8} = asn1_wrapper:encode('Prim','IntCon',-257),
 
285
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon8)),
 
286
 
 
287
    ?line {ok,BytesCon9} = asn1_wrapper:encode('Prim','IntCon',-1234567890),
 
288
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntCon',lists:flatten(BytesCon9)),
 
289
 
 
290
    ?line {ok,BytesCon10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
291
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesCon10)),
 
292
 
 
293
 
 
294
 
 
295
    %%==========================================================
 
296
    %% IntPri ::=  [PRIVATE 41] INTEGER 
 
297
    %%==========================================================
 
298
 
 
299
    ?line {ok,BytesPri1} = asn1_wrapper:encode('Prim','IntPri',4),
 
300
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri1)),
 
301
 
 
302
    ?line {ok,BytesPri2} = asn1_wrapper:encode('Prim','IntPri',444),
 
303
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri2)),
 
304
 
 
305
    ?line {ok,BytesPri3} = asn1_wrapper:encode('Prim','IntPri',123456789),
 
306
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri3)),
 
307
 
 
308
    ?line {ok,BytesPri4} = asn1_wrapper:encode('Prim','IntPri',12345678901234567890),
 
309
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri4)),
 
310
 
 
311
    ?line {ok,BytesPri5} = asn1_wrapper:encode('Prim','IntPri',-100),
 
312
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri5)),
 
313
 
 
314
    ?line {ok,BytesPri6} = asn1_wrapper:encode('Prim','IntPri',-255),
 
315
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri6)),
 
316
 
 
317
    ?line {ok,BytesPri7} = asn1_wrapper:encode('Prim','IntPri',-256),
 
318
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri7)),
 
319
 
 
320
    ?line {ok,BytesPri8} = asn1_wrapper:encode('Prim','IntPri',-257),
 
321
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri8)),
 
322
 
 
323
    ?line {ok,BytesPri9} = asn1_wrapper:encode('Prim','IntPri',-1234567890),
 
324
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntPri',lists:flatten(BytesPri9)),
 
325
 
 
326
    ?line {ok,BytesPri10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
327
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesPri10)),
 
328
 
 
329
 
 
330
 
 
331
    %%==========================================================
 
332
    %% IntApp ::=  [APPLICATION 42] INTEGER 
 
333
    %%==========================================================
 
334
 
 
335
    ?line {ok,BytesApp1} = asn1_wrapper:encode('Prim','IntApp',4),
 
336
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp1)),
 
337
 
 
338
    ?line {ok,BytesApp2} = asn1_wrapper:encode('Prim','IntApp',444),
 
339
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp2)),
 
340
 
 
341
    ?line {ok,BytesApp3} = asn1_wrapper:encode('Prim','IntApp',123456789),
 
342
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp3)),
 
343
 
 
344
    ?line {ok,BytesApp4} = asn1_wrapper:encode('Prim','IntApp',12345678901234567890),
 
345
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp4)),
 
346
 
 
347
    ?line {ok,BytesApp5} = asn1_wrapper:encode('Prim','IntApp',-100),
 
348
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp5)),
 
349
 
 
350
    ?line {ok,BytesApp6} = asn1_wrapper:encode('Prim','IntApp',-255),
 
351
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp6)),
 
352
 
 
353
    ?line {ok,BytesApp7} = asn1_wrapper:encode('Prim','IntApp',-256),
 
354
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp7)),
 
355
 
 
356
    ?line {ok,BytesApp8} = asn1_wrapper:encode('Prim','IntApp',-257),
 
357
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp8)),
 
358
 
 
359
    ?line {ok,BytesApp9} = asn1_wrapper:encode('Prim','IntApp',-1234567890),
 
360
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntApp',lists:flatten(BytesApp9)),
 
361
 
 
362
    ?line {ok,BytesApp10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
363
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesApp10)),
 
364
 
 
365
 
 
366
    %%==========================================================
 
367
    %% IntExpCon ::=  [50] EXPLICIT INTEGER 
 
368
    %%==========================================================
 
369
 
 
370
    ?line {ok,BytesExpCon1} = asn1_wrapper:encode('Prim','IntExpCon',4),
 
371
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon1)),
 
372
 
 
373
    ?line {ok,BytesExpCon2} = asn1_wrapper:encode('Prim','IntExpCon',444),
 
374
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon2)),
 
375
 
 
376
    ?line {ok,BytesExpCon3} = asn1_wrapper:encode('Prim','IntExpCon',123456789),
 
377
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon3)),
 
378
 
 
379
    ?line {ok,BytesExpCon4} = asn1_wrapper:encode('Prim','IntExpCon',12345678901234567890),
 
380
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon4)),
 
381
 
 
382
    ?line {ok,BytesExpCon5} = asn1_wrapper:encode('Prim','IntExpCon',-100),
 
383
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon5)),
 
384
 
 
385
    ?line {ok,BytesExpCon6} = asn1_wrapper:encode('Prim','IntExpCon',-255),
 
386
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon6)),
 
387
 
 
388
    ?line {ok,BytesExpCon7} = asn1_wrapper:encode('Prim','IntExpCon',-256),
 
389
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon7)),
 
390
 
 
391
    ?line {ok,BytesExpCon8} = asn1_wrapper:encode('Prim','IntExpCon',-257),
 
392
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon8)),
 
393
 
 
394
    ?line {ok,BytesExpCon9} = asn1_wrapper:encode('Prim','IntExpCon',-1234567890),
 
395
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntExpCon',lists:flatten(BytesExpCon9)),
 
396
 
 
397
    ?line {ok,BytesExpCon10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
398
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesExpCon10)),
 
399
 
 
400
    %%==========================================================
 
401
    %% IntExpPri ::=  [PRIVATE 51] EXPLICIT INTEGER 
 
402
    %%==========================================================
 
403
 
 
404
    ?line {ok,BytesExpPri1} = asn1_wrapper:encode('Prim','IntExpPri',4),
 
405
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri1)),
 
406
 
 
407
    ?line {ok,BytesExpPri2} = asn1_wrapper:encode('Prim','IntExpPri',444),
 
408
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri2)),
 
409
 
 
410
    ?line {ok,BytesExpPri3} = asn1_wrapper:encode('Prim','IntExpPri',123456789),
 
411
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri3)),
 
412
 
 
413
    ?line {ok,BytesExpPri4} = asn1_wrapper:encode('Prim','IntExpPri',12345678901234567890),
 
414
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri4)),
 
415
 
 
416
    ?line {ok,BytesExpPri5} = asn1_wrapper:encode('Prim','IntExpPri',-100),
 
417
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri5)),
 
418
 
 
419
    ?line {ok,BytesExpPri6} = asn1_wrapper:encode('Prim','IntExpPri',-255),
 
420
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri6)),
 
421
 
 
422
    ?line {ok,BytesExpPri7} = asn1_wrapper:encode('Prim','IntExpPri',-256),
 
423
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri7)),
 
424
 
 
425
    ?line {ok,BytesExpPri8} = asn1_wrapper:encode('Prim','IntExpPri',-257),
 
426
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri8)),
 
427
 
 
428
    ?line {ok,BytesExpPri9} = asn1_wrapper:encode('Prim','IntExpPri',-1234567890),
 
429
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntExpPri',lists:flatten(BytesExpPri9)),
 
430
 
 
431
    ?line {ok,BytesExpPri10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
432
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesExpPri10)),
 
433
 
 
434
    %%==========================================================
 
435
    %% IntExpApp ::=  [APPLICATION 52] EXPLICIT INTEGER 
 
436
    %%==========================================================
 
437
 
 
438
    ?line {ok,BytesExpApp1} = asn1_wrapper:encode('Prim','IntExpApp',4),
 
439
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp1)),
 
440
 
 
441
    ?line {ok,BytesExpApp2} = asn1_wrapper:encode('Prim','IntExpApp',444),
 
442
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp2)),
 
443
 
 
444
    ?line {ok,BytesExpApp3} = asn1_wrapper:encode('Prim','IntExpApp',123456789),
 
445
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp3)),
 
446
 
 
447
    ?line {ok,BytesExpApp4} = asn1_wrapper:encode('Prim','IntExpApp',12345678901234567890),
 
448
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp4)),
 
449
 
 
450
    ?line {ok,BytesExpApp5} = asn1_wrapper:encode('Prim','IntExpApp',-100),
 
451
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp5)),
 
452
 
 
453
    ?line {ok,BytesExpApp6} = asn1_wrapper:encode('Prim','IntExpApp',-255),
 
454
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp6)),
 
455
 
 
456
    ?line {ok,BytesExpApp7} = asn1_wrapper:encode('Prim','IntExpApp',-256),
 
457
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp7)),
 
458
 
 
459
    ?line {ok,BytesExpApp8} = asn1_wrapper:encode('Prim','IntExpApp',-257),
 
460
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp8)),
 
461
 
 
462
    ?line {ok,BytesExpApp9} = asn1_wrapper:encode('Prim','IntExpApp',-1234567890),
 
463
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntExpApp',lists:flatten(BytesExpApp9)),
 
464
 
 
465
    ?line {ok,BytesExpApp10} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
466
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesExpApp10)),
 
467
 
 
468
 
 
469
    %%==========================================================
 
470
    %% IntEnum ::=  INTEGER {first(1),last(31)} 
 
471
    %%==========================================================
 
472
 
 
473
    ?line {ok,BytesEnum1} = asn1_wrapper:encode('Prim','IntEnum',4),
 
474
    ?line {ok,4} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum1)),
 
475
 
 
476
    ?line {ok,BytesEnum2} = asn1_wrapper:encode('Prim','IntEnum',444),
 
477
    ?line {ok,444} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum2)),
 
478
 
 
479
    ?line {ok,BytesEnum3} = asn1_wrapper:encode('Prim','IntEnum',123456789),
 
480
    ?line {ok,123456789} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum3)),
 
481
 
 
482
    ?line {ok,BytesEnum4} = asn1_wrapper:encode('Prim','IntEnum',12345678901234567890),
 
483
    ?line {ok,12345678901234567890} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum4)),
 
484
 
 
485
    ?line {ok,BytesEnum5} = asn1_wrapper:encode('Prim','IntEnum',-100),
 
486
    ?line {ok,-100} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum5)),
 
487
 
 
488
    ?line {ok,BytesEnum6} = asn1_wrapper:encode('Prim','IntEnum',-255),
 
489
    ?line {ok,-255} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum6)),
 
490
 
 
491
    ?line {ok,BytesEnum7} = asn1_wrapper:encode('Prim','IntEnum',-256),
 
492
    ?line {ok,-256} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum7)),
 
493
 
 
494
    ?line {ok,BytesEnum8} = asn1_wrapper:encode('Prim','IntEnum',-257),
 
495
    ?line {ok,-257} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum8)),
 
496
 
 
497
    ?line {ok,BytesEnum9} = asn1_wrapper:encode('Prim','IntEnum',-1234567890),
 
498
    ?line {ok,-1234567890} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum9)),
 
499
 
 
500
    ?line {ok,BytesEnum910} = asn1_wrapper:encode('Prim','Int',-2147483648),
 
501
    ?line {ok,-2147483648} = asn1_wrapper:decode('Prim','Int',lists:flatten(BytesEnum910)),
 
502
 
 
503
 
 
504
    ?line {ok,BytesEnum10} = asn1_wrapper:encode('Prim','IntEnum',first),
 
505
    ?line {ok,first} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum10)),
 
506
 
 
507
    ?line {ok,BytesEnum11} = asn1_wrapper:encode('Prim','IntEnum',last),
 
508
    ?line {ok,last} = asn1_wrapper:decode('Prim','IntEnum',lists:flatten(BytesEnum11)),
 
509
    
 
510
 
 
511
 
 
512
    ok.
 
513
 
 
514
 
 
515
 
 
516
enum(Rules) ->
 
517
 
 
518
    %%==========================================================
 
519
    %% Enum ::=  ENUMERATED {monday(1),tuesday(2),wednesday(3),thursday(4),
 
520
    %%                       friday(5),saturday(6),sunday(7)}
 
521
    %%==========================================================
 
522
 
 
523
    ?line {ok,BytesEnum1} = asn1_wrapper:encode('Prim','Enum',monday),
 
524
    ?line {ok,monday} = asn1_wrapper:decode('Prim','Enum',lists:flatten(BytesEnum1)),
 
525
 
 
526
    ?line {ok,BytesEnum2} = asn1_wrapper:encode('Prim','Enum',thursday),
 
527
    ?line {ok,thursday} = asn1_wrapper:decode('Prim','Enum',lists:flatten(BytesEnum2)),
 
528
 
 
529
 
 
530
    ?line case asn1_wrapper:erule(Rules) of
 
531
              ber -> 
 
532
                  ?line {error,{asn1,{_,4}}} = 
 
533
                      case catch asn1_wrapper:encode('Prim','Enum',4) of Enum -> Enum end,
 
534
                  ok;
 
535
              per ->
 
536
                  ?line {error,{asn1,{_,4}}} = 
 
537
                      case catch asn1_wrapper:encode('Prim','Enum',4) of Enum -> Enum end,
 
538
                  ok
 
539
          end,
 
540
    ok.
 
541
 
 
542
 
 
543
 
 
544
obj_id(Rules) ->
 
545
 
 
546
    %%==========================================================
 
547
    %% ObjId ::= OBJECT IDENTIFIER
 
548
    %%==========================================================
 
549
 
 
550
    ?line {ok,Bytes1} = asn1_wrapper:encode('Prim','ObjId',{0,22,3}),
 
551
    ?line {ok,{0,22,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes1)),
 
552
 
 
553
    ?line {ok,Bytes2} = asn1_wrapper:encode('Prim','ObjId',{1,39,3}),
 
554
    ?line {ok,{1,39,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes2)),
 
555
 
 
556
    ?line {ok,Bytes3} = asn1_wrapper:encode('Prim','ObjId',{2,100,3}),
 
557
    ?line {ok,{2,100,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes3)),
 
558
 
 
559
    ?line {ok,Bytes4} = asn1_wrapper:encode('Prim','ObjId',{2,16303,3}),
 
560
    ?line {ok,{2,16303,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes4)),
 
561
 
 
562
    ?line case asn1_wrapper:erule(Rules) of
 
563
              ber -> 
 
564
                  ?line {ok,Bytes5} = asn1_wrapper:encode('Prim','ObjId',{2,16304,3}),
 
565
                  ?line {ok,{2,16304,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes5)),
 
566
                  ok;
 
567
              per ->
 
568
                  ?line {ok,Bytes5} = asn1_wrapper:encode('Prim','ObjId',{2,16304,3}),
 
569
                  ?line {ok,{2,16304,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes5)),
 
570
%%                ?line test_server:format("~p~n",[Kurt]),
 
571
%                 ?line {ok,{2,16304,3}} = asn1_wrapper:decode('Prim','ObjId',lists:flatten(Bytes5)),
 
572
                  ok
 
573
          end,
 
574
 
 
575
 
 
576
 
 
577
    ok.
 
578
 
 
579
rel_oid(_Rules) ->
 
580
 
 
581
    %%==========================================================
 
582
    %% RelOid ::= RELATIVE-OID
 
583
    %%==========================================================
 
584
 
 
585
    ?line {ok,Bytes1} = asn1_wrapper:encode('Prim','RelOid',{0,22,3}),
 
586
    ?line {ok,{0,22,3}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes1)),
 
587
 
 
588
    ?line {ok,Bytes2} = asn1_wrapper:encode('Prim','RelOid',{1,39,3}),
 
589
    ?line {ok,{1,39,3}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes2)),
 
590
 
 
591
    ?line {ok,Bytes3} = asn1_wrapper:encode('Prim','RelOid',{2,100,3}),
 
592
    ?line {ok,{2,100,3}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes3)),
 
593
 
 
594
    ?line {ok,Bytes4} = asn1_wrapper:encode('Prim','RelOid',{2,16303,3}),
 
595
    ?line {ok,{2,16303,3}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes4)),
 
596
    
 
597
    ?line {ok,Bytes5} = asn1_wrapper:encode('Prim','RelOid',{2,16304,3}),
 
598
    ?line {ok,{2,16304,3}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes5)),
 
599
    
 
600
    ?line {ok,Bytes6} = asn1_wrapper:encode('Prim','RelOid',{8,16304,16#ffff}),
 
601
    ?line {ok,{8,16304,16#ffff}} = asn1_wrapper:decode('Prim','RelOid',lists:flatten(Bytes6)),
 
602
    
 
603
 
 
604
 
 
605
    ok.
 
606
 
 
607
 
 
608
 
 
609
 
 
610
 
 
611
null(_Rules) ->
 
612
 
 
613
    %%==========================================================
 
614
    %% Null ::= NULL
 
615
    %%==========================================================
 
616
 
 
617
    ?line {ok,Bytes1} = asn1_wrapper:encode('Prim','Null',monday),
 
618
    ?line {ok,'NULL'} = asn1_wrapper:decode('Prim','Null',lists:flatten(Bytes1)),
 
619
 
 
620
 
 
621
 
 
622
ok.
 
623
 
 
624
 
 
625
 
 
626
real(_Rules) ->
 
627
    %%==========================================================
 
628
    %% AngleInRadians ::= REAL
 
629
    %%==========================================================
 
630
    
 
631
    %% Base 2
 
632
    ?line {ok,Bytes1} = asn1_wrapper:encode('Real','AngleInRadians',{1,2,1}),
 
633
    ?line {ok,{1,2,1}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes1),
 
634
 
 
635
    ?line {ok,Bytes2} = asn1_wrapper:encode('Real','AngleInRadians',{129,2,1}),
 
636
    ?line {ok,{129,2,1}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes2),
 
637
 
 
638
    ?line {ok,Bytes3} = asn1_wrapper:encode('Real','AngleInRadians',{128,2,1}),
 
639
    ?line {ok,{1,2,8}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes3),
 
640
 
 
641
    ?line {ok,Bytes4} = asn1_wrapper:encode('Real','AngleInRadians',{128,2,-7}),
 
642
    ?line {ok,{1,2,0}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes4),
 
643
 
 
644
    ?line {ok,Bytes5} = asn1_wrapper:encode('Real','AngleInRadians',{16#f1f1f1,2,128}),
 
645
    ?line {ok,{16#f1f1f1,2,128}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes5),
 
646
 
 
647
    %% Base 10, tuple format
 
648
    ?line {ok,Bytes6} = asn1_wrapper:encode('Real','AngleInRadians',{1,10,1}),
 
649
    ?line {ok,"1.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes6),
 
650
    
 
651
    ?line {ok,Bytes7} = asn1_wrapper:encode('Real','AngleInRadians',{100,10,1}),
 
652
    ?line {ok,"1.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes7),
 
653
 
 
654
    ?line {ok,Bytes8} = asn1_wrapper:encode('Real','AngleInRadians',{-100,10,1}),
 
655
    ?line {ok,"-1.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes8),
 
656
 
 
657
    ?line {ok,Bytes9} = asn1_wrapper:encode('Real','AngleInRadians',{00002,10,1}),
 
658
    ?line {ok,"2.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes9),
 
659
 
 
660
    ?line {ok,Bytes10} = asn1_wrapper:encode('Real','AngleInRadians',{123000,10,0}),
 
661
    ?line {ok,"123.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes10),
 
662
 
 
663
    ?line {ok,Bytes11} = asn1_wrapper:encode('Real','AngleInRadians',{123456789,10,123456789}),
 
664
    ?line {ok,"123456789.E123456789"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes11),
 
665
 
 
666
    ?line {ok,Bytes12} = asn1_wrapper:encode('Real','AngleInRadians',{-12345,10,-12345}),
 
667
    ?line {ok,"-12345.E-12345"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes12),
 
668
 
 
669
    %% Base 10, string format NR3
 
670
    
 
671
    ?line {ok,Bytes13} = asn1_wrapper:encode('Real','AngleInRadians',"123.123E123"),
 
672
    ?line {ok,"123123.E120"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes13),
 
673
 
 
674
    ?line {ok,Bytes14} = asn1_wrapper:encode('Real','AngleInRadians',"0.0E0"),
 
675
    ?line {ok,"0.E+0"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes14),
 
676
 
 
677
    ?line {ok,Bytes15} = asn1_wrapper:encode('Real','AngleInRadians',"0.0123"),
 
678
    ?line {ok,"123.E-4"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes15),
 
679
 
 
680
    ?line {ok,Bytes16} = asn1_wrapper:encode('Real','AngleInRadians',"0"),
 
681
    ?line {ok,"0.E+0"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes16),
 
682
    
 
683
    ?line {ok,Bytes17} = asn1_wrapper:encode('Real','AngleInRadians',"-123.45"),
 
684
    ?line {ok,"-12345.E-2"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes17),
 
685
 
 
686
    ?line {ok,Bytes18} = 
 
687
        asn1_wrapper:encode('Real','AngleInRadians',"123456789E123456789"),
 
688
    ?line {ok,"123456789.E123456789"} = 
 
689
        asn1_wrapper:decode('Real','AngleInRadians',Bytes18),
 
690
 
 
691
    ?line {ok,Bytes19} = asn1_wrapper:encode('Real','AngleInRadians',"01.000E1"),
 
692
    ?line {ok,"1.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes19),
 
693
 
 
694
    ?line {ok,Bytes20} = asn1_wrapper:encode('Real','AngleInRadians',"120.0001"),
 
695
    ?line {ok,"1200001.E-4"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes20).