Skip to content

Commit 3d81910

Browse files
committed
テストやコメントを更新
1 parent 58b8597 commit 3d81910

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/jsone.erl

+9-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ try_encode(JsonValue, Options) ->
130130
end.
131131

132132

133-
%%--------------------------------------------------------------------------------
134133
%% Internal Functions
135-
%%--------------------------------------------------------------------------------
134+
135+
136136
-spec create_decoders([decode_option()], json:decoders()) -> json:decoders().
137137
create_decoders([], Acc) ->
138138
Acc;
@@ -148,7 +148,7 @@ create_decoders([{keys, attempt_atom} | Options], Acc) ->
148148
end,
149149
create_decoders(Options, Acc#{object_push => ObjectPush});
150150
create_decoders(Options, Acc) ->
151-
%% 不明なオプションがあった
151+
%% 不明なオプションが指定されていたらエラーにする
152152
erlang:error(badarg, [Options, Acc]).
153153

154154

@@ -177,6 +177,7 @@ build_encode_options([undefined_as_null | Options], Acc) ->
177177
build_encode_options([{float_format, Format} | Options], Acc) ->
178178
build_encode_options(Options, Acc#encode_options{float_format = Format});
179179
build_encode_options(Options, Acc) ->
180+
%% 不明なオプションが指定されていたらエラーにする
180181
erlang:error(badarg, [Options, Acc]).
181182

182183

@@ -212,8 +213,13 @@ encode(Value, Encoder, _Options) ->
212213

213214

214215
decode_test() ->
216+
%% Basic decoding.
215217
?assertEqual(#{<<"foo">> => 1}, decode(~'{"foo": 1}')),
218+
219+
%% `attempt_atom` option.
216220
?assertEqual(#{foo => 1}, decode(~'{"foo": 1}', [{keys, attempt_atom}])),
221+
?assertEqual(#{<<"no_existing_atom">> => 1}, decode(~'{"no_existing_atom": 1}', [{keys, attempt_atom}])),
222+
217223
ok.
218224

219225

0 commit comments

Comments
 (0)