aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/nif_SUITE_data
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <egil@erlang.org>2016-05-11 17:49:45 +0200
committerBjörn-Egil Dahlberg <egil@erlang.org>2016-05-11 17:49:45 +0200
commitd3cde2d80d1cbcbbb70e4b8057a4f3772b7fa97f (patch)
tree6bb10917dffcd1d2f3f369ae8826e6105f9bd1bd /erts/emulator/test/nif_SUITE_data
parent8d8d8c3817988a50ed1e058e73b247ce0a8c3616 (diff)
downloadotp-d3cde2d80d1cbcbbb70e4b8057a4f3772b7fa97f.tar.gz
otp-d3cde2d80d1cbcbbb70e4b8057a4f3772b7fa97f.tar.bz2
otp-d3cde2d80d1cbcbbb70e4b8057a4f3772b7fa97f.zip
erts: Add tests for enif_snprintf
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r--erts/emulator/test/nif_SUITE_data/nif_SUITE.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
index 11e5dab58e..951b6959a8 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -2109,6 +2109,23 @@ static ERL_NIF_TERM port_command(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar
return atom_true;
}
+static ERL_NIF_TERM format_term(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
+{
+ ErlNifBinary obin;
+ unsigned int size;
+
+ if (!enif_get_uint(env, argv[0], &size))
+ return enif_make_badarg(env);
+ if (!enif_alloc_binary(size,&obin))
+ return enif_make_badarg(env);
+
+ if (enif_snprintf((char*)obin.data, (size_t)size, "%T", argv[1]) < 0)
+ return atom_false;
+
+ return enif_make_binary(env,&obin);
+}
+
+
static ErlNifFunc nif_funcs[] =
{
{"lib_version", 0, lib_version},
@@ -2190,7 +2207,8 @@ static ErlNifFunc nif_funcs[] =
{"is_port_alive_nif", 1, is_port_alive},
{"term_to_binary_nif", 2, term_to_binary},
{"binary_to_term_nif", 3, binary_to_term},
- {"port_command_nif", 2, port_command}
+ {"port_command_nif", 2, port_command},
+ {"format_term_nif", 2, format_term}
};
ERL_NIF_INIT(nif_SUITE,nif_funcs,load,reload,upgrade,unload)