aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testConstraints.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-10-17 15:22:49 +0200
committerBjörn Gustavsson <[email protected]>2013-10-17 15:54:29 +0200
commit719f789cebec004b350153e1f001303d6713f4a6 (patch)
tree774bd334dae867f22a6432dbda1e73cb0f36d881 /lib/asn1/test/testConstraints.erl
parent20641fe0f2ea745873fc7557448d3a7deb1bd639 (diff)
downloadotp-719f789cebec004b350153e1f001303d6713f4a6.tar.gz
otp-719f789cebec004b350153e1f001303d6713f4a6.tar.bz2
otp-719f789cebec004b350153e1f001303d6713f4a6.zip
Fix complicated union of INTEGER constraints
A constraint that was an union of integer ranges: Type ::= INTEGER (lb1..ub1 | ... | lbN..ubN) would sometimes (depending on the values) not all always be properly combined to a single effective range, but would become: Type ::= INTEGER (lb2..ub2) (lb3..ub3) If that type was used in a SEQUENCE: S ::= SEQUENCE { v Type } the constraint would be simplified, taking the intersection of the ranges.
Diffstat (limited to 'lib/asn1/test/testConstraints.erl')
-rw-r--r--lib/asn1/test/testConstraints.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl
index 03a09492af..0c6653ccd9 100644
--- a/lib/asn1/test/testConstraints.erl
+++ b/lib/asn1/test/testConstraints.erl
@@ -182,6 +182,15 @@ int_constraints(Rules) ->
roundtrip('ShorterExt', "abcde"),
roundtrip('ShorterExt', "abcdef"),
+ %%==========================================================
+ %% Unions of INTEGER constraints
+ %%==========================================================
+ seq_roundtrip(Rules, 'SeqOverlapping', 'SeqNonOverlapping', 7580),
+ seq_roundtrip(Rules, 'SeqOverlapping', 'SeqNonOverlapping', 9600),
+ seq_roundtrip(Rules, 'SeqOverlapping', 'SeqNonOverlapping', 18050),
+ seq_roundtrip(Rules, 'SeqOverlapping', 'SeqNonOverlapping', 19000),
+ seq_roundtrip(Rules, 'SeqOverlapping', 'SeqNonOverlapping', 26900),
+
ok.
%% PER: Ensure that if the lower bound is Lb, Lb+16#80 is encoded
@@ -240,3 +249,12 @@ range_error(Per, Type, Value) when Per =:= per; Per =:= uper ->
%% on encode.
{error,_} = 'Constraints':encode(Type, Value),
ok.
+
+seq_roundtrip(Rules, Seq1, Seq2, Val) ->
+ Enc = roundtrip(Seq1, {Seq1,Val}),
+ case Rules of
+ ber ->
+ roundtrip(Seq2, {Seq2,Val});
+ _ ->
+ roundtrip_enc(Seq2, {Seq2,Val}, Enc)
+ end.