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.

32 rindas
940 B

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. -module(jiffy_16_attempt_atom_tests).
  4. -include_lib("eunit/include/eunit.hrl").
  5. attempt_atom_test_() ->
  6. Opts = [attempt_atom],
  7. _ = key_is_atom,
  8. Cases = [
  9. {<<"{\"key_no_atom\":1}">>, {[{<<"key_no_atom">>, 1}]}},
  10. {<<"{\"key_is_atom\":1}">>, {[{key_is_atom, 1}]}}
  11. ],
  12. {"Test attempt_atom", lists:map(fun({Data, Result}) ->
  13. ?_assertEqual(Result, jiffy:decode(Data, Opts))
  14. end, Cases)}.
  15. -ifndef(JIFFY_NO_MAPS).
  16. attempt_atom_map_test_() ->
  17. Opts = [attempt_atom, return_maps],
  18. _ = key_is_atom,
  19. Cases = [
  20. {<<"{\"key_no_atom\":1}">>, #{<<"key_no_atom">> => 1}},
  21. {<<"{\"key_is_atom\":1}">>, #{key_is_atom => 1}}
  22. ],
  23. {"Test attempt_atom_map", lists:map(fun({Data, Result}) ->
  24. ?_assertEqual(Result, jiffy:decode(Data, Opts))
  25. end, Cases)}.
  26. -endif.