small modification to jsx_test

This commit is contained in:
alisdair sullivan 2010-08-10 11:52:18 -07:00
parent 1617c878f5
commit 55540969a6

View file

@ -24,7 +24,9 @@
-module(jsx_test). -module(jsx_test).
-author("alisdairsullivan@yahoo.ca"). -author("alisdairsullivan@yahoo.ca").
-ifndef(test).
-export([test/0]). -export([test/0]).
-endif.
-ifdef(test). -ifdef(test).
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
@ -39,16 +41,17 @@ test() -> erlang:error(notest).
-else. -else.
fake_test_() ->
[ {"fake test", ?_assert(true)} ].
jsx_decoder_test_() -> jsx_decoder_test_() ->
jsx_decoder_gen(load_tests("./test/cases"), [utf8, utf16, {utf16, little}, utf32, {utf32, little}]). jsx_decoder_gen(load_tests("./test/cases"), [utf8, utf16, {utf16, little}, utf32, {utf32, little}]).
jsx_decoder_gen([Test|Rest], []) -> jsx_decoder_gen([_Test|Rest], []) ->
jsx_decoder_gen(Rest, [utf8, utf16, {utf16, little}, utf32, {utf32, little}]); jsx_decoder_gen(Rest, [utf8, utf16, {utf16, little}, utf32, {utf32, little}]);
jsx_decoder_gen([], _) -> jsx_decoder_gen([], _) ->
[]; [];
jsx_decoder_gen([Test|Rest] = Tests, [Encoding|Encodings]) -> jsx_decoder_gen([Test|_] = Tests, [Encoding|Encodings]) ->
Name = lists:flatten(proplists:get_value(name, Test) ++ " :: " ++ io_lib:format("~p", [Encoding])), Name = lists:flatten(proplists:get_value(name, Test) ++ " :: " ++ io_lib:format("~p", [Encoding])),
JSON = unicode:characters_to_binary(proplists:get_value(json, Test), unicode, Encoding), JSON = unicode:characters_to_binary(proplists:get_value(json, Test), unicode, Encoding),
JSX = proplists:get_value(jsx, Test), JSX = proplists:get_value(jsx, Test),