Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
1.0 KiB

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. -module(jiffy_17_copy_strings_tests).
  4. -include_lib("eunit/include/eunit.hrl").
  5. check_binaries({Props}) when is_list(Props) ->
  6. lists:all(fun({Key, Value}) ->
  7. check_binaries(Key) andalso check_binaries(Value)
  8. end, Props);
  9. check_binaries(Values) when is_list(Values) ->
  10. lists:all(fun(Value) ->
  11. check_binaries(Value)
  12. end, Values);
  13. check_binaries(Bin) when is_binary(Bin) ->
  14. io:format("~s :: ~p ~p", [Bin, byte_size(Bin), binary:referenced_byte_size(Bin)]),
  15. byte_size(Bin) == binary:referenced_byte_size(Bin);
  16. check_binaries(_Bin) ->
  17. true.
  18. copy_strings_test_() ->
  19. Opts = [copy_strings],
  20. Cases = [
  21. <<"\"foo\"">>,
  22. <<"[\"bar\"]">>,
  23. <<"{\"foo\":\"bar\"}">>,
  24. <<"{\"foo\":[\"bar\"]}">>
  25. ],
  26. {"Test copy_strings", lists:map(fun(Json) ->
  27. EJson = jiffy:decode(Json, Opts),
  28. ?_assert(check_binaries(EJson))
  29. end, Cases)}.