Sha256: e3a9900f0afaf7bf74c108707e324651432260afdff2a640bc8df46d64a8511b

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

#! /usr/bin/env escript

main([]) ->
    code:add_pathz("ebin/"),
    check_good(),
    check_errors().

check_good() ->
    lists:map(fun
        ({J, E}) ->
            E = ejson:decode(J),
            J = ejson:encode(E);
        ({J, E, J2}) ->
            E = ejson:decode(J),
            J2 = ejson:encode(E)
        end,
    good()).

check_errors() ->
    lists:map(fun(E) ->
        ok = case (catch ejson:decode(E)) of
            {invalid_json, _} -> ok;
            Error ->
                io:format("Error: ~p~n", [E]),
                Error
        end
    end, errors()).

good() ->
    [
        {<<"\"\"">>, <<"">>},
        {<<"\"0\"">>, <<"0">>},
        {<<"\"foo\"">>, <<"foo">>},
        {<<"\"\\\"foobar\\\"\"">>, <<"\"foobar\"">>},
        {<<"\"\\n\\n\\n\"">>, <<"\n\n\n">>},
        {<<"\"\\\" \\b\\f\\r\\n\\t\\\"\"">>, <<"\" \b\f\r\n\t\"">>},
        {<<"\"foo\\u0005bar\"">>, <<"foo", 5, "bar">>},
        {<<"\"\\uFFFF\"">>, <<239, 191, 191>>},
        {<<"\"\\uD834\\uDD1E\"">>, <<240, 157, 132, 158>>},
        {<<"\"\\uD834foo\\uDD1E\"">>, <<237, 160, 180, "foo", 237, 180, 158>>}
    ].

errors() ->
    [
        <<"\"", 0, "\"">>,
        <<"\"\\g\"">>,
        % CouchDB-345
        <<"\"",78,69,73,77,69,78,32,70,216,82,82,32,70,65,69,78,33,"\"">>
    ].

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capricorn-2.0.11 erlang/lib/ejson/test/strings.escript
capricorn-2.0.10 erlang/lib/ejson/test/strings.escript
capricorn-2.0.9 erlang/lib/ejson/test/strings.escript