aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/nif_SUITE_data
diff options
context:
space:
mode:
authorTuncer Ayaz <[email protected]>2010-05-07 18:12:05 +0200
committerRaimo Niskanen <[email protected]>2010-05-24 14:25:13 +0200
commit8c8663f32f0e9fc2b9483e2b99cee5f703640e88 (patch)
treeb3b191d8230fd664a597c4565be916342cc0b752 /erts/emulator/test/nif_SUITE_data
parent08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a (diff)
downloadotp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.tar.gz
otp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.tar.bz2
otp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.zip
erl_nif: add enif_get_atom_length and enif_get_list_length
Add new NIF API functions - enif_get_atom_length - enif_get_list_length Signed-off-by: Tuncer Ayaz <[email protected]>
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r--erts/emulator/test/nif_SUITE_data/nif_SUITE.c32
1 files changed, 31 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 22d0d5a93b..4d010c58a5 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -661,6 +661,35 @@ static ERL_NIF_TERM check_is(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]
return ok_atom;
}
+/*
+ * argv[0] atom with length of 6
+ * argv[1] list with length of 6
+ * argv[2] empty list
+ * argv[3] not an atom
+ * argv[4] not a list
+ */
+static ERL_NIF_TERM length_test(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
+{
+ unsigned len;
+
+ if (!enif_get_atom_length(env, argv[0], &len) || len != 6)
+ return enif_make_badarg(env);
+
+ if (!enif_get_list_length(env, argv[1], &len) || len != 6)
+ return enif_make_badarg(env);
+
+ if (!enif_get_list_length(env, argv[2], &len) || len != 0)
+ return enif_make_badarg(env);
+
+ if (enif_get_atom_length(env, argv[3], &len))
+ return enif_make_badarg(env);
+
+ if (enif_get_list_length(env, argv[4], &len))
+ return enif_make_badarg(env);
+
+ return enif_make_atom(env, "ok");
+}
+
static ErlNifFunc nif_funcs[] =
{
{"lib_version", 0, lib_version},
@@ -687,7 +716,8 @@ static ErlNifFunc nif_funcs[] =
{"release_resource", 1, release_resource},
{"last_resource_dtor_call", 0, last_resource_dtor_call},
{"make_new_resource", 2, make_new_resource},
- {"check_is", 10, check_is}
+ {"check_is", 10, check_is},
+ {"length_test", 5, length_test}
};