aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testPrimStrings.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/test/testPrimStrings.erl')
-rw-r--r--lib/asn1/test/testPrimStrings.erl33
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/asn1/test/testPrimStrings.erl b/lib/asn1/test/testPrimStrings.erl
index f8b0c5b05a..66415afe87 100644
--- a/lib/asn1/test/testPrimStrings.erl
+++ b/lib/asn1/test/testPrimStrings.erl
@@ -255,11 +255,16 @@ octet_string(Rules) ->
fragmented_octet_string(Rules),
S255 = lists:seq(1, 255),
- FixedStrings = {'OsFixedStrings',true,"","1","12","345",true,
- S255,[$a|S255],[$a,$b|S255],397},
- roundtrip('OsFixedStrings', FixedStrings),
+ Strings = {type,true,"","1","12","345",true,
+ S255,[$a|S255],[$a,$b|S255],397},
+ p_roundtrip('OsFixedStrings', Strings),
+ p_roundtrip('OsFixedStringsExt', Strings),
+ p_roundtrip('OsVarStringsExt', Strings),
+ ShortenedStrings = shorten_by_two(Strings),
+ p_roundtrip('OsFixedStringsExt', ShortenedStrings),
+ p_roundtrip('OsVarStringsExt', ShortenedStrings),
ok.
-
+
fragmented_octet_string(Erules) ->
K16 = 1 bsl 14,
K32 = K16 + K16,
@@ -438,6 +443,15 @@ other_strings(_Rules) ->
roundtrip('IA5Visible', lists:seq($\s, $~)),
+ S255 = lists:seq(0, 127) ++ lists:seq(1, 127),
+ Strings = {type,true,"","1","12","345",true,"6789",true,
+ S255,[$a|S255],[$a,$b|S255],397},
+ p_roundtrip('IA5FixedStrings', Strings),
+ p_roundtrip('IA5FixedStringsExt', Strings),
+ p_roundtrip('IA5VarStringsExt', Strings),
+ ShortenedStrings = shorten_by_two(Strings),
+ p_roundtrip('IA5VarStringsExt', ShortenedStrings),
+
ok.
@@ -709,6 +723,17 @@ wrapper_utf8_binary_to_list(L) when is_list(L) ->
wrapper_utf8_binary_to_list(B) ->
asn1rt:utf8_binary_to_list(B).
+shorten_by_two(Tuple) ->
+ L = [case E of
+ [_,_|T] -> T;
+ _ -> E
+ end || E <- tuple_to_list(Tuple)],
+ list_to_tuple(L).
+
+p_roundtrip(Type, Value0) ->
+ Value = setelement(1, Value0, Type),
+ roundtrip(Type, Value).
+
roundtrip(Type, Value) ->
{ok,Encoded} = 'PrimStrings':encode(Type, Value),
{ok,Value} = 'PrimStrings':decode(Type, Encoded),