diff options
author | Björn Gustavsson <[email protected]> | 2014-09-22 14:21:55 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-01-12 11:40:24 +0100 |
commit | b92e491aa5bfbaefb0f938bbb245a580837cb8c8 (patch) | |
tree | 23d176c1983dd35a25d398b7ab29ef62afc82788 /lib/asn1/test/testValueTest.erl | |
parent | d73a835b66911935024019fd55089a1e0f7a81d2 (diff) | |
download | otp-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/testValueTest.erl')
-rw-r--r-- | lib/asn1/test/testValueTest.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/asn1/test/testValueTest.erl b/lib/asn1/test/testValueTest.erl index fdd8b006e2..d9cc3de5eb 100644 --- a/lib/asn1/test/testValueTest.erl +++ b/lib/asn1/test/testValueTest.erl @@ -63,4 +63,24 @@ main() -> 42 = M:otherInteger(), {'IntegerSeq',42} = M:integerSeq1(), + %% Value from object + 2 = M:'int-from-object-1'(), + 4 = M:'int-from-object-2'(), + roundtrip_error('II', 1), + roundtrip('II', 2), + roundtrip('II', 3), + roundtrip('II', 4), + roundtrip_error('II', 5), + ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('ValueTest', T, V). + +roundtrip_error(T, V) -> + try asn1_test_lib:roundtrip('ValueTest', T, V) of + ok -> + test_server:fail() + catch _:_ -> + ok + end. |