aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-09-19 15:42:40 +0200
committerBjörn Gustavsson <[email protected]>2015-01-12 11:40:23 +0100
commitd73a835b66911935024019fd55089a1e0f7a81d2 (patch)
tree64ca826f3d906848da58d5075f63bcd1686931b9 /lib/asn1/test
parentcb6a006acbcec5aae7cf94f163f101fb6c9d439a (diff)
downloadotp-d73a835b66911935024019fd55089a1e0f7a81d2.tar.gz
otp-d73a835b66911935024019fd55089a1e0f7a81d2.tar.bz2
otp-d73a835b66911935024019fd55089a1e0f7a81d2.zip
Check INTEGER values better
There is duplicated effort in that validate_integer() checks whether the integer value is valid, and then normalize_integer() does mostly the same work in order to convert the value to an integer. Eliminate the validate_integer() function and incorporate its checks into normalize_integer(). Also produce proper error messages.
Diffstat (limited to 'lib/asn1/test')
-rw-r--r--lib/asn1/test/asn1_SUITE_data/ValueTest.asn11
-rw-r--r--lib/asn1/test/error_SUITE.erl13
-rw-r--r--lib/asn1/test/testValueTest.erl5
3 files changed, 28 insertions, 1 deletions
diff --git a/lib/asn1/test/asn1_SUITE_data/ValueTest.asn b/lib/asn1/test/asn1_SUITE_data/ValueTest.asn
index dae9ae498a..8db2fcf17d 100644
--- a/lib/asn1/test/asn1_SUITE_data/ValueTest.asn
+++ b/lib/asn1/test/asn1_SUITE_data/ValueTest.asn
@@ -50,4 +50,15 @@ my-universalstring UniversalString ::= {"This is a capital A: ",
greekCapitalLetterSigma,
"; try and spot the difference!"}
+-- Useful parameterized SEQUENCE.
+ParamSeq{Type} ::= SEQUENCE {
+ a Type
+}
+
+-- Integer values.
+IntegerSeq ::= ParamSeq{INTEGER}
+someInteger INTEGER ::= 42
+integerSeq1 IntegerSeq ::= { a otherInteger }
+otherInteger INTEGER ::= someInteger
+
END
diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl
index 713f80cbee..36ec7a8203 100644
--- a/lib/asn1/test/error_SUITE.erl
+++ b/lib/asn1/test/error_SUITE.erl
@@ -255,6 +255,11 @@ values(Config) ->
" os1 OCTET STRING ::= \"abc\"\n"
" os2 OCTET STRING ::= 42\n"
" os3 OCTET STRING ::= { 1, 3 }\n"
+ " os4 OCTET STRING ::= '1234'H\n"
+
+ " int1 INTEGER ::= \"string\"\n"
+ " int2 INTEGER ::= os4\n"
+ " int3 INTEGER ::= not-defined\n"
"END\n">>},
{error,
[
@@ -263,7 +268,13 @@ values(Config) ->
{structured_error,{M,3},asn1ct_check,
illegal_octet_string_value},
{structured_error,{M,4},asn1ct_check,
- illegal_octet_string_value}
+ illegal_octet_string_value},
+ {structured_error,{M,6},asn1ct_check,
+ illegal_integer_value},
+ {structured_error,{M,7},asn1ct_check,
+ illegal_integer_value},
+ {structured_error,{M,8},asn1ct_check,
+ illegal_integer_value}
]
} = run(P, Config),
ok.
diff --git a/lib/asn1/test/testValueTest.erl b/lib/asn1/test/testValueTest.erl
index 8359930256..fdd8b006e2 100644
--- a/lib/asn1/test/testValueTest.erl
+++ b/lib/asn1/test/testValueTest.erl
@@ -58,4 +58,9 @@ main() ->
[0,0,3,145],
"; try and spot the difference!"] = M:'my-universalstring'(),
+ %% Integers
+ 42 = M:someInteger(),
+ 42 = M:otherInteger(),
+ {'IntegerSeq',42} = M:integerSeq1(),
+
ok.