Increase JSON conversation coverage

This commit is contained in:
Gavin M. Roy 2016-05-17 14:39:43 -04:00
parent 9708fb23c8
commit 723bcdcb75
2 changed files with 8 additions and 3 deletions

View File

@ -29,10 +29,10 @@ convert_binary_values([{K, V}|T], Accum) when is_binary(V) ->
convert_binary_values([{K, V}|T], Accum) ->
convert_binary_values(T, lists:append(Accum, [{binary_to_list(K), V}]));
convert_binary_values([H|T], Accum) when is_binary(H) ->
convert_binary_values(T, lists:append(Accum, [binary_to_list(H)]));
convert_binary_values(T, lists:append(Accum, [binary_to_list(H)]));
convert_binary_values([H|T], Accum) when is_integer(H) ->
convert_binary_values(T, lists:append(Accum, [H]));
convert_binary_values(T, lists:append(Accum, [H]));
convert_binary_values([H|T], Accum) when is_atom(H) ->
convert_binary_values(T, lists:append(Accum, [H]));
convert_binary_values(T, lists:append(Accum, [H]));
convert_binary_values([H|T], Accum) ->
convert_binary_values(T, lists:append(Accum, convert_binary_values(H, []))).

View File

@ -48,6 +48,11 @@ parse_test_() ->
{"key","aws:cloudformation:stack-name"},
{"value","prod-us-east-1-ecs-1"}]}
],
?assertEqual(Expectation, httpc_aws_json:decode(Value))
end},
{"list values", fun() ->
Value = "{\"misc\": [\"foo\", true, 123]\}",
Expectation = [{"misc", ["foo", true, 123]}],
?assertEqual(Expectation, httpc_aws_json:decode(Value))
end}
].