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

« back to all changes in this revision

Viewing changes to lib/asn1/test/testSeqOfIndefinite.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 1999-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(testSeqOfIndefinite).
 
21
 
 
22
-export([compile/3]).
 
23
-export([main/0]).
 
24
 
 
25
-include("test_server.hrl").
 
26
 
 
27
%-record('Seq1',{bool1, int1, seq1 = asn1_DEFAULT}).
 
28
%-record('Seq2',{seq2 = asn1_DEFAULT, bool2, int2}).
 
29
%-record('Seq3',{bool3, seq3 = asn1_DEFAULT, int3}).
 
30
%-record('Seq4',{seq41 = asn1_DEFAULT, seq42 = asn1_DEFAULT, seq43 = asn1_DEFAULT}).
 
31
%-record('SeqIn',{boolIn, intIn}).
 
32
%-record('SeqCho',{bool1, int1, seq1 = asn1_DEFAULT}).
 
33
%-record('SeqChoInline',{bool1, int1, seq1 = asn1_DEFAULT}).
 
34
%-record('SeqChoOfInline_SEQOF',{bool1, int1, seq1 = asn1_DEFAULT}).
 
35
%-record('SeqEmp',{seq1}).
 
36
%-record('Empty',{}).
 
37
 
 
38
 
 
39
 
 
40
compile(Config,Rules,Opts) ->
 
41
 
 
42
    ?line DataDir = ?config(data_dir,Config),
 
43
    ?line OutDir = ?config(priv_dir,Config),
 
44
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
45
    ?line Options = [Rules,{outdir,OutDir}]++Opts,
 
46
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-Constants-1",Options),
 
47
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-DataTypes-1",Options),
 
48
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-21-4",Options),
 
49
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-20-4",Options),
 
50
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-19-4",Options),
 
51
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-18-4",Options),
 
52
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-17-4",Options),
 
53
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-15-4",Options),
 
54
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-14-4",Options),
 
55
    ?line ok = asn1ct:compile(DataDir ++ "Mvrasn-11-4",Options),
 
56
    ?line ok = asn1ct:compile(DataDir ++ "SeqOf",Options).
 
57
    
 
58
main() ->
 
59
    ?line ok = test(isd),
 
60
    ?line ok = test(isd2),
 
61
    ?line ok = test(dsd),
 
62
    ?line ok = test(ul_res),
 
63
    ?line ok = test(prim),
 
64
    ?line ok = test(seqofseq),
 
65
    ?line ok = test('InsertSubscriberDataArg'). % OTP-4232
 
66
 
 
67
test(isd)->
 
68
    EncPdu = [48,128,129,7,145,148,113,50,1,0,241,131,1,0,176,128,5,0,161,128,48,22,2,1,1,144,2,241,33,145,4,0,1,2,3,146,3,36,131,16,148,2,1,42,48,35,2,1,2,144,2,241,33,145,4,255,255,255,255,146,3,37,147,18,147,0,148,13,7,67,79,77,80,65,78,89,4,67,79,77,53,48,28,2,1,3,144,2,241,33,146,3,26,98,31,148,14,9,67,79,77,80,65,78,89,49,50,3,67,79,77,0,0,0,0,152,1,2,0,0],
 
69
    
 
70
    ?line {ok,_} = asn1_wrapper:decode('Mvrasn-11-4',
 
71
                                'InsertSubscriberDataArg',
 
72
                                EncPdu),
 
73
    ok;
 
74
 
 
75
 
76
% Problems with indefinite length encoding !!!
 
77
 
78
test(isd2)->
 
79
    EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 176, 128, 161, 128, 48, 128, 2, 1, 1, 144, 2, 241, 33, 145, 4, 255, 23, 12, 1, 146, 3, 9, 17, 1, 147, 0, 148, 13, 7, 67, 79, 77, 80, 65, 78, 89, 4, 67, 79, 77, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 
80
    
 
81
    ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4',
 
82
                                'InsertSubscriberDataArg',
 
83
                                EncPdu),
 
84
 
 
85
    ok;
 
86
 
 
87
 
88
% Is doing fine, although there is indefinite encoding used... !!!
 
89
 
90
test(dsd)->
 
91
    EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 170, 2, 5, 0, 0, 0, 0, 0],
 
92
    
 
93
    ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4',
 
94
                                'DeleteSubscriberDataArg',
 
95
                                EncPdu),
 
96
 
 
97
    ok;
 
98
 
 
99
%
 
100
% Is doing fine !!!
 
101
 
102
test(ul_res)->
 
103
    EncPdu = [48, 9, 4, 7, 145, 148, 113, 66, 16, 17, 241],
 
104
    
 
105
    ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4',
 
106
                                'UpdateGprsLocationRes',
 
107
                                EncPdu),
 
108
 
 
109
    ok;
 
110
 
 
111
test(prim) ->
 
112
    ?line {ok,Bytes} = asn1_wrapper:encode('SeqOf','SeqOfInt',[10,20,30]),
 
113
    ?line [Tag,_Len|Ints] = lists:flatten(Bytes),
 
114
    ?line {ok,[10,20,30]} = 
 
115
        asn1_wrapper:decode('SeqOf','SeqOfInt',[Tag,128|Ints] ++ [0,0]),
 
116
    ok;
 
117
 
 
118
test(seqofseq) ->
 
119
    {ok,_V} = asn1_wrapper:decode('Mvrasn-DataTypes-1',
 
120
                 'SentParameters',
 
121
                 [48,
 
122
                  129,
 
123
                  190,
 
124
                  161,
 
125
                  128,
 
126
                  4,
 
127
                  16,
 
128
                  176,
 
129
                  197,
 
130
                  182,
 
131
                  68,
 
132
                  41,
 
133
                  243,
 
134
                  188,
 
135
                  205,
 
136
                  123,
 
137
                  13,
 
138
                  9,
 
139
                  145,
 
140
                  206,
 
141
                  200,
 
142
                  144,
 
143
                  102,
 
144
                  4,
 
145
                  4,
 
146
                  176,
 
147
                  197,
 
148
                  182,
 
149
                  68,
 
150
                  4,
 
151
                  8,
 
152
                  41,
 
153
                  243,
 
154
                  188,
 
155
                  205,
 
156
                  123,
 
157
                  13,
 
158
                  9,
 
159
                  145,
 
160
                  0,
 
161
                  0,
 
162
                  161,
 
163
                  128,
 
164
                  4,
 
165
                  16,
 
166
                  39,
 
167
                  0,
 
168
                  3,
 
169
                  117,
 
170
                  35,
 
171
                  189,
 
172
                  130,
 
173
                  21,
 
174
                  42,
 
175
                  104,
 
176
                  49,
 
177
                  194,
 
178
                  212,
 
179
                  24,
 
180
                  151,
 
181
                  234,
 
182
                  4,
 
183
                  4,
 
184
                  39,
 
185
                  0,
 
186
                  3,
 
187
                  117,
 
188
                  4,
 
189
                  8,
 
190
                  35,
 
191
                  189,
 
192
                  130,
 
193
                  21,
 
194
                  42,
 
195
                  104,
 
196
                  49,
 
197
                  194,
 
198
                  0,
 
199
                  0,
 
200
                  161,
 
201
                  128,
 
202
                  4,
 
203
                  16,
 
204
                  62,
 
205
                  207,
 
206
                  166,
 
207
                  59,
 
208
                  71,
 
209
                  29,
 
210
                  37,
 
211
                  97,
 
212
                  120,
 
213
                  25,
 
214
                  132,
 
215
                  80,
 
216
                  144,
 
217
                  251,
 
218
                  161,
 
219
                  123,
 
220
                  4,
 
221
                  4,
 
222
                  62,
 
223
                  207,
 
224
                  166,
 
225
                  59,
 
226
                  4,
 
227
                  8,
 
228
                  71,
 
229
                  29,
 
230
                  37,
 
231
                  97,
 
232
                  120,
 
233
                  25,
 
234
                  132,
 
235
                  80,
 
236
                  0,
 
237
                  0,
 
238
                  161,
 
239
                  128,
 
240
                  4,
 
241
                  16,
 
242
                  95,
 
243
                  183,
 
244
                  173,
 
245
                  151,
 
246
                  17,
 
247
                  76,
 
248
                  148,
 
249
                  146,
 
250
                  248,
 
251
                  102,
 
252
                  127,
 
253
                  215,
 
254
                  102,
 
255
                  224,
 
256
                  39,
 
257
                  60,
 
258
                  4,
 
259
                  4,
 
260
                  95,
 
261
                  183,
 
262
                  173,
 
263
                  151,
 
264
                  4,
 
265
                  8,
 
266
                  17,
 
267
                  76,
 
268
                  148,
 
269
                  146,
 
270
                  248,
 
271
                  102,
 
272
                  127,
 
273
                  215,
 
274
                  0,
 
275
                  0,
 
276
                  161,
 
277
                  128,
 
278
                  4,
 
279
                  16,
 
280
                  41,
 
281
                  198,
 
282
                  247,
 
283
                  157,
 
284
                  117,
 
285
                  190,
 
286
                  203,
 
287
                  170,
 
288
                  91,
 
289
                  146,
 
290
                  88,
 
291
                  91,
 
292
                  223,
 
293
                  220,
 
294
                  188,
 
295
                  16,
 
296
                  4,
 
297
                  4,
 
298
                  41,
 
299
                  198,
 
300
                  247,
 
301
                  157,
 
302
                  4,
 
303
                  8,
 
304
                  117,
 
305
                  190,
 
306
                  203,
 
307
                  170,
 
308
                  91,
 
309
                  146,
 
310
                  88,
 
311
                  91,
 
312
                  0,
 
313
                  0]),
 
314
    ok;
 
315
test('InsertSubscriberDataArg') ->
 
316
    {ok,_V} =
 
317
        asn1_wrapper:decode('Mvrasn-11-4','InsertSubscriberDataArg',
 
318
                            [16#30,16#80,16#81,16#07,16#91,16#94,
 
319
                             16#71,16#92,16#00,16#35,16#80,16#83,
 
320
                             16#01,16#00,16#A6,16#06,16#04,16#01,
 
321
                             16#21,16#04,16#01,16#22,16#B0,16#80,
 
322
                             16#05,16#00,16#A1,16#80,16#30,16#1A,
 
323
                             16#02,16#01,16#01,16#90,16#02,16#F1,
 
324
                             16#21,16#92,16#03,16#0D,16#92,16#1F,
 
325
                             16#94,16#0C,16#03,16#53,16#49,16#4D,
 
326
                             16#03,16#47,16#53,16#4E,16#03,16#4C,
 
327
                             16#4B,16#50,16#00,16#00,16#00,16#00,
 
328
                             16#98,16#01,16#00,16#00,16#00]),
 
329
    ok.