aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testMaps.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-02-09 11:45:09 +0100
committerGitHub <[email protected]>2017-02-09 11:45:09 +0100
commit9fd347f4fb1443ff5a342177bc8780e174cd67da (patch)
treea2546ff745886c25e565b9b9bef6047256060ce3 /lib/asn1/test/testMaps.erl
parentaff4e82fce59e4eaefa84ed0d1dd5c40927637e5 (diff)
parent8a7f914affce3102e4889c2973ea2d2e99ad633d (diff)
downloadotp-9fd347f4fb1443ff5a342177bc8780e174cd67da.tar.gz
otp-9fd347f4fb1443ff5a342177bc8780e174cd67da.tar.bz2
otp-9fd347f4fb1443ff5a342177bc8780e174cd67da.zip
Merge pull request #1327 from bjorng/bjorn/asn1/maps-instead-of-records/OTP-14004
Teach the ASN.1 compiler the 'maps' option OTP-14219
Diffstat (limited to 'lib/asn1/test/testMaps.erl')
-rw-r--r--lib/asn1/test/testMaps.erl50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/asn1/test/testMaps.erl b/lib/asn1/test/testMaps.erl
new file mode 100644
index 0000000000..45dd2255ba
--- /dev/null
+++ b/lib/asn1/test/testMaps.erl
@@ -0,0 +1,50 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2017. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+-module(testMaps).
+
+-export([main/1]).
+
+main(_) ->
+ M = 'Maps',
+ true = M:maps(),
+
+ true = M:xy1() =:= #{x=>42,y=>17},
+ true = M:xy2() =:= #{x=>0,y=>0},
+ true = M:xy3() =:= #{x=>0,y=>999},
+ true = M:s1() =:= #{xy=>#{x=>100,y=>100}},
+
+ roundtrip('XY', M:xy1()),
+ roundtrip('XY', M:xy2()),
+ roundtrip('XY', M:xy3()),
+ roundtrip('XY', #{}, #{x=>0,y=>0}),
+
+ roundtrip('S', M:s1()),
+ roundtrip('S', #{}, #{xy=>#{x=>100,y=>100}}),
+ roundtrip('S', #{os=><<1,2,3>>}, #{xy=>#{x=>100,y=>100},
+ os=><<1,2,3>>}),
+
+ ok.
+
+roundtrip(Type, Value) ->
+ roundtrip(Type, Value, Value).
+
+roundtrip(Type, Value, Expected) ->
+ asn1_test_lib:roundtrip('Maps', Type, Value, Expected).