From 079858313bb508d4b3ef4a8ea7a3240156c6b294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 29 Oct 2014 12:32:29 +0100 Subject: Clean up constraint checking --- lib/asn1/test/asn1_SUITE_data/Constraints.py | 26 ++++++++++++++++++++++++++ lib/asn1/test/testConstraints.erl | 13 +++++++++++++ 2 files changed, 39 insertions(+) (limited to 'lib/asn1/test') diff --git a/lib/asn1/test/asn1_SUITE_data/Constraints.py b/lib/asn1/test/asn1_SUITE_data/Constraints.py index bee619348a..2df95da8a2 100644 --- a/lib/asn1/test/asn1_SUITE_data/Constraints.py +++ b/lib/asn1/test/asn1_SUITE_data/Constraints.py @@ -161,4 +161,30 @@ int-holder-2 INT-HOLDER ::= { ID 4 OBJ int-holder-1 } IntObjectConstr ::= INTEGER (int-holder-2.&obj.&id..int-holder-2.&id) +-- +-- INTEGER constraints defined using named INTEGERs. +-- + +ConstrainedNamedInt ::= INTEGER {v1(42)} (v1) +constrainedNamedInt-1 INTEGER {v1(42)} (v1) ::= 42 +constrainedNamedInt-2 ConstrainedNamedInt ::= 100 + +SeqWithNamedInt ::= SEQUENCE { + int INTEGER {v2(7)} (v2) +} + +-- +-- Cover simpletable constraint checking code. +-- + +ContentInfo ::= SEQUENCE { + contentType ContentType +} + +Contents TYPE-IDENTIFIER ::= { + {OCTET STRING IDENTIFIED BY {2 1 1 1 1 1 1}} +} + +ContentType ::= TYPE-IDENTIFIER.&id({Contents}) + END diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl index aab4f1d4c6..5d65cb8d73 100644 --- a/lib/asn1/test/testConstraints.erl +++ b/lib/asn1/test/testConstraints.erl @@ -240,6 +240,19 @@ int_constraints(Rules) -> roundtrip('IntObjectConstr', 4), range_error(Rules, 'IntObjectConstr', 5), + + %%========================================================== + %% INTEGER constraints defined using named INTEGERs. + %%========================================================== + 42 = 'Constraints':'constrainedNamedInt-1'(), + 100 = 'Constraints':'constrainedNamedInt-2'(), + range_error(Rules, 'ConstrainedNamedInt', 41), + roundtrip('ConstrainedNamedInt', v1), + range_error(Rules, 'ConstrainedNamedInt', 43), + + range_error(Rules, 'SeqWithNamedInt', {'SeqWithNamedInt',-100}), + roundtrip('SeqWithNamedInt', {'SeqWithNamedInt',v2}), + ok. %% PER: Ensure that if the lower bound is Lb, Lb+16#80 is encoded -- cgit v1.2.3