aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testContextSwitchingTypes.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-01-25 10:38:32 +0100
committerBjörn Gustavsson <[email protected]>2013-01-25 10:38:32 +0100
commit33468dba74d92f83c93e317a28d468c26a699848 (patch)
treebf9672203d9dbf65844e81647134e9b4bdcedfa0 /lib/asn1/test/testContextSwitchingTypes.erl
parent1342146f167f780d0b558fb78fdf421aef84b64f (diff)
parentb06cbaf8cf12a9b6dcbdc6eab873a6212206ef58 (diff)
downloadotp-33468dba74d92f83c93e317a28d468c26a699848.tar.gz
otp-33468dba74d92f83c93e317a28d468c26a699848.tar.bz2
otp-33468dba74d92f83c93e317a28d468c26a699848.zip
Merge branch 'bjorn/asn1/further-cleanup/OTP-10588'
* bjorn/asn1/further-cleanup/OTP-10588: (28 commits) Don't export encode_disp/2 and decode_disp/2 in generated modules Remove vestiges of support for the {TypeName,Value} notation Simplify the functions for decoding lengths per,uper: Optimize decoding of the remaining data types per,uper: Optimize decoding of the remaining string types Share all code for dec_gen_prim/3 between per/uper back-ends per,uper: Optimize decoding of the string data types testPrimStrings: Test some constraints By default, encode BIT STRING to bitstrings Teach encode functions to accept a bitstring term for a BIT STRING Fix EXTERNAL 1990/1994 conversion information loss uper: Look up some SizeConstraints at compile-time Enumeration decoding: Don't emit a default clause if it cannot match Slightly optimize per encoding of large INTEGERs with constraints BER run-time: Refactor decoding of string data types Refactor decoding of BIT STRINGs Optimize encoding of ENUMERATED in per and uper Remove the unused run-time modules eldap: Remove calls to undocumented asn1rt* functions BER: Correct bug in 'undec_rest' ...
Diffstat (limited to 'lib/asn1/test/testContextSwitchingTypes.erl')
-rw-r--r--lib/asn1/test/testContextSwitchingTypes.erl52
1 files changed, 33 insertions, 19 deletions
diff --git a/lib/asn1/test/testContextSwitchingTypes.erl b/lib/asn1/test/testContextSwitchingTypes.erl
index 4f67942922..f06cc7c117 100644
--- a/lib/asn1/test/testContextSwitchingTypes.erl
+++ b/lib/asn1/test/testContextSwitchingTypes.erl
@@ -52,22 +52,36 @@ test(Config) ->
check_EXTERNAL({'EXTERNAL',Identif,DVD,DV})->
- ?line ok=check_EXTERNAL_Idef(Identif),
- ?line ok = check_EXTERNAL_DVD(DVD),
- ?line ok = check_EXTERNAL_DV(DV).
-check_EXTERNAL_Idef({Alt,_}) when Alt=='context-negotiation';
- Alt=='presentation-context-id';
- Alt==syntax ->
- ok;
-check_EXTERNAL_Idef(I) ->
- {error,"failed on identification alternative",I}.
-check_EXTERNAL_DVD(DVD) when is_list(DVD) ->
- ok;
-check_EXTERNAL_DVD(asn1_NOVALUE) ->
- ok;
-check_EXTERNAL_DVD(DVD) ->
- {error,"failed on data-value-descriptor alternative",DVD}.
-check_EXTERNAL_DV(DV) when is_list(DV);is_binary(DV) ->
- ok;
-check_EXTERNAL_DV(DV) ->
- {error,"failed on data-value alternative",DV}.
+ %% EXTERNAL in the 1994 format.
+ case Identif of
+ {'context-negotiation',_} ->
+ ok;
+ {'presentation-context-id',Id} ->
+ true = is_integer(Id);
+ {syntax,ObjId} ->
+ check_object_identifier(ObjId)
+ end,
+ check_EXTERNAL_DVD(DVD),
+ check_EXTERNAL_DV(DV);
+check_EXTERNAL({'EXTERNAL',ObjId,IndirectRef,Descriptor,Enc})->
+ %% EXTERNAL in the 1990 format.
+ check_object_identifier(ObjId),
+ true = is_integer(IndirectRef),
+ true = is_binary(Descriptor) orelse is_list(Descriptor),
+ case Enc of
+ {arbitrary,_} -> ok;
+ {'single-ASN1-type',_} -> ok;
+ {'octet-aligned',_} -> ok
+ end.
+
+check_EXTERNAL_DVD(DVD) when is_list(DVD) -> ok;
+check_EXTERNAL_DVD(asn1_NOVALUE) -> ok.
+
+check_EXTERNAL_DV(DV) when is_list(DV); is_binary(DV) -> ok.
+
+check_object_identifier(Tuple) when is_tuple(Tuple) ->
+ %% An OBJECT IDENTIFIER is a tuple with integer elements.
+ case [E || E <- tuple_to_list(Tuple),
+ not is_integer(E)] of
+ [] -> ok
+ end.