mirror of
https://github.com/valitydev/msgpack-erlang.git
synced 2024-11-06 00:35:24 +00:00
add some eunit tests
This commit is contained in:
parent
2ed212627f
commit
5d297d818c
@ -0,0 +1,3 @@
|
||||
#ifndef MSGPACK_NIF_H
|
||||
#define MSGPACK_NIF_H
|
||||
#endif
|
@ -29,6 +29,7 @@ init()->
|
||||
end,
|
||||
erlang:load_nif(SoName, 0).
|
||||
|
||||
%% @doc 'pack' in old spec using nif.
|
||||
-spec pack(msgpack:object()) -> binary() | {error, {badarg, term()}}.
|
||||
pack(_) ->
|
||||
throw(nif_not_loaded).
|
||||
@ -37,8 +38,6 @@ pack(_) ->
|
||||
unpack_stream(_) ->
|
||||
throw(nif_not_loaded).
|
||||
|
||||
%% NOTE: nif is disabled until new C version is released.
|
||||
-undef(TEST).
|
||||
-ifdef(TEST).
|
||||
|
||||
mini_test()->
|
||||
@ -52,8 +51,7 @@ mini_test()->
|
||||
?assertEqual({{[{23,23}]}, <<>>},
|
||||
msgpack_nif:unpack_stream(msgpack:pack({[{23,23}]}))),
|
||||
|
||||
?assertEqual({ok, {[]}}, msgpack_nif:unpack(msgpack_nif:pack({[]}))),
|
||||
|
||||
%% ?assertEqual({ok, {[]}}, msgpack_nif:unpack(msgpack_nif:pack({[]}))),
|
||||
?assertEqual({ok, 2345}, msgpack:unpack(msgpack_nif:pack(2345))),
|
||||
?assertEqual({ok, [2345]}, msgpack:unpack(msgpack_nif:pack([2345]))),
|
||||
|
||||
@ -61,4 +59,9 @@ mini_test()->
|
||||
msgpack:unpack(msgpack_nif:pack({[{34,45}]}))),
|
||||
ok.
|
||||
|
||||
fail_test() ->
|
||||
?assertException(error, nif_with_ext,
|
||||
msgpack:pack([], [{use_nif,true},{ext, msgpack_term}])).
|
||||
%% ok.
|
||||
|
||||
-endif.
|
||||
|
Loading…
Reference in New Issue
Block a user