aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-03-06 16:17:09 +0100
committerSverker Eriksson <[email protected]>2014-03-06 20:10:20 +0100
commit78796d03ac341da53e9c8b7f8d69cc3c0a949c14 (patch)
treeb49c336cf7cbdd7d950b0232de87eb1588775895
parent6941af88ad016141f568279f065cb181074f1f9f (diff)
downloadotp-78796d03ac341da53e9c8b7f8d69cc3c0a949c14.tar.gz
otp-78796d03ac341da53e9c8b7f8d69cc3c0a949c14.tar.bz2
otp-78796d03ac341da53e9c8b7f8d69cc3c0a949c14.zip
erl_interface: test decode/encode of maps
-rw-r--r--lib/erl_interface/test/ei_decode_encode_SUITE.erl4
-rw-r--r--lib/erl_interface/test/ei_decode_encode_SUITE_data/ei_decode_encode_test.c28
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/erl_interface/test/ei_decode_encode_SUITE.erl b/lib/erl_interface/test/ei_decode_encode_SUITE.erl
index b0952d4b04..7caec6ac04 100644
--- a/lib/erl_interface/test/ei_decode_encode_SUITE.erl
+++ b/lib/erl_interface/test/ei_decode_encode_SUITE.erl
@@ -132,6 +132,10 @@ test_ei_decode_encode(Config) when is_list(Config) ->
send_rec(P, {atom, Pid, Port, Ref}),
send_rec(P, [atom, Pid, Port, Ref]),
send_rec(P, [atom | Fun]),
+ send_rec(P, #{}),
+ send_rec(P, #{key => value}),
+ send_rec(P, maps:put(Port, Ref, #{key => value, key2 => Pid})),
+
?line runner:recv_eot(P),
ok.
diff --git a/lib/erl_interface/test/ei_decode_encode_SUITE_data/ei_decode_encode_test.c b/lib/erl_interface/test/ei_decode_encode_SUITE_data/ei_decode_encode_test.c
index 9a50aef7b6..1ef17d4161 100644
--- a/lib/erl_interface/test/ei_decode_encode_SUITE_data/ei_decode_encode_test.c
+++ b/lib/erl_interface/test/ei_decode_encode_SUITE_data/ei_decode_encode_test.c
@@ -166,6 +166,20 @@ struct Type nil_type = {
my_encode_nil, my_x_encode_nil
};
+int my_encode_map_header(char *buf, int *index, union my_obj* obj)
+{
+ return ei_encode_map_header(buf, index, obj->arity);
+}
+int my_x_encode_map_header(ei_x_buff* x, union my_obj* obj)
+{
+ return ei_x_encode_map_header(x, (long)obj->arity);
+}
+
+struct Type map_type = {
+ "map_header", "arity", (decodeFT*)ei_decode_map_header,
+ my_encode_map_header, my_x_encode_map_header
+};
+
#define BUFSZ 2000
@@ -225,7 +239,7 @@ void decode_encode(struct Type** tv, int nobj)
return;
}
- if (t != &tuple_type && t != &list_type) {
+ if (t != &tuple_type && t != &list_type && t != &map_type) {
size2 = 0;
err = ei_skip_term(inp, &size2);
if (err != 0) {
@@ -442,7 +456,19 @@ TESTCASE(test_ei_decode_encode)
struct Type* list[] = { &list_type, &my_atom_type, &fun_type };
decode_encode(list, 3);
}
+ decode_encode_one(&map_type); /* #{} */
+ { /* #{atom => atom}*/
+ struct Type* map[] = { &map_type, &my_atom_type, &my_atom_type };
+ decode_encode(map, 3);
+ }
+ { /* #{atom => atom, atom => pid, port => ref }*/
+ struct Type* map[] = { &map_type,
+ &my_atom_type, &my_atom_type, &port_type,
+ &my_atom_type, &pid_type, &ref_type
+ };
+ decode_encode(map, 7);
+ }
report(1);
}