aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/error_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-09-22 14:21:55 +0200
committerBjörn Gustavsson <[email protected]>2015-01-12 11:40:24 +0100
commitb92e491aa5bfbaefb0f938bbb245a580837cb8c8 (patch)
tree23d176c1983dd35a25d398b7ab29ef62afc82788 /lib/asn1/test/error_SUITE.erl
parentd73a835b66911935024019fd55089a1e0f7a81d2 (diff)
downloadotp-b92e491aa5bfbaefb0f938bbb245a580837cb8c8.tar.gz
otp-b92e491aa5bfbaefb0f938bbb245a580837cb8c8.tar.bz2
otp-b92e491aa5bfbaefb0f938bbb245a580837cb8c8.zip
Refactor code involving calls to get_fieldname_element/3
Refactor and clean up code. While at it, add error handling and test cases. (Also add test cases for the existing values in ValueTest.asn while we are it.) Add support for defining INTEGER constants by extracting fields from objects. Example: int-from-object INTEGER ::= object.&id When extracting values from objects in constraints, only one level of extraction would work. That is, the following would work: SomeName ::= INTEGER (object.&int) but not: SomeName ::= INTEGER (object.&obj.&int)
Diffstat (limited to 'lib/asn1/test/error_SUITE.erl')
-rw-r--r--lib/asn1/test/error_SUITE.erl73
1 files changed, 71 insertions, 2 deletions
diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl
index 36ec7a8203..630daf75c6 100644
--- a/lib/asn1/test/error_SUITE.erl
+++ b/lib/asn1/test/error_SUITE.erl
@@ -20,9 +20,9 @@
-module(error_SUITE).
-export([suite/0,all/0,groups/0,
already_defined/1,bitstrings/1,
- classes/1,enumerated/1,
+ classes/1,constraints/1,enumerated/1,
imports/1,instance_of/1,integers/1,objects/1,
- parameterization/1,values/1]).
+ object_field_extraction/1,parameterization/1,values/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -36,11 +36,13 @@ groups() ->
[already_defined,
bitstrings,
classes,
+ constraints,
enumerated,
imports,
instance_of,
integers,
objects,
+ object_field_extraction,
parameterization,
values]}].
@@ -108,6 +110,29 @@ classes(Config) ->
]} = run(P, Config),
ok.
+constraints(Config) ->
+ M = 'Constraints',
+ P = {M,
+ <<"Constraints DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n"
+ " II-1 ::= INTEGER (holder-1.&obj)\n"
+ " II-2 ::= INTEGER ('1234'H<..20)\n"
+ " II-3 ::= INTEGER (1..<\"abc\")\n"
+
+ " HOLDER ::= CLASS {\n"
+ " &obj HOLDER OPTIONAL\n"
+ " }\n"
+
+ " holder-1 HOLDER ::= { &obj holder-2 }\n"
+ " holder-2 HOLDER ::= { }\n"
+ "END\n">>},
+ {error,
+ [
+ {structured_error,{M,2},asn1ct_check,illegal_value},
+ {structured_error,{M,3},asn1ct_check,illegal_integer_value},
+ {structured_error,{M,4},asn1ct_check,illegal_integer_value}
+ ]} = run(P, Config),
+ ok.
+
enumerated(Config) ->
M = 'Enumerated',
P = {M,
@@ -235,6 +260,36 @@ objects(Config) ->
} = run(P, Config),
ok.
+object_field_extraction(Config) ->
+ M = 'ObjectFieldExtraction',
+ P = {M,
+ <<"ObjectFieldExtraction DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n"
+
+ " DataObjSet DATA-CLASS ::= {\n"
+ " holder-object-1.&int,\n"
+ " ...\n"
+ " }\n"
+
+ " holder-object-1 HOLDER-CLASS ::= {\n"
+ " &int 42\n"
+ " }\n"
+
+ " HOLDER-CLASS ::= CLASS {\n"
+ " &int INTEGER\n"
+ " }\n"
+
+ " DATA-CLASS ::= CLASS {\n"
+ " &id INTEGER\n"
+ " }\n"
+
+ "END\n">>},
+ {error,
+ [
+ {structured_error,{M,2},asn1ct_check,illegal_object}
+ ]
+ } = run(P, Config),
+ ok.
+
parameterization(Config) ->
M = 'Parameterization',
P = {M,
@@ -260,6 +315,16 @@ values(Config) ->
" int1 INTEGER ::= \"string\"\n"
" int2 INTEGER ::= os4\n"
" int3 INTEGER ::= not-defined\n"
+ " int4 INTEGER ::= holder-1.&str\n"
+ " int5 INTEGER ::= holder-2.&obj\n"
+
+ " HOLDER ::= CLASS {\n"
+ " &str IA5String,\n"
+ " &obj HOLDER OPTIONAL\n"
+ " }\n"
+
+ " holder-1 HOLDER ::= { &str \"xyz\" }\n"
+ " holder-2 HOLDER ::= { &str \"xyz\", &obj holder-1 }\n"
"END\n">>},
{error,
[
@@ -274,6 +339,10 @@ values(Config) ->
{structured_error,{M,7},asn1ct_check,
illegal_integer_value},
{structured_error,{M,8},asn1ct_check,
+ illegal_integer_value},
+ {structured_error,{M,9},asn1ct_check,
+ illegal_integer_value},
+ {structured_error,{M,10},asn1ct_check,
illegal_integer_value}
]
} = run(P, Config),