Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Testing decoding of defaults.

  • Loading branch information...
commit a7d95a7118537ce7f394ca78812119f2c4805504 1 parent 132d91a
Erik Søe Sørensen eriksoe authored
Showing with 12 additions and 2 deletions.
  1. +0 −1  src/protobuffs_generic.erl
  2. +12 −1 test/protobuffs_tests.erl
1  src/protobuffs_generic.erl
View
@@ -209,7 +209,6 @@ to_record(RecordInfo, FieldList) ->
end.
add_record_field(Field, Record, RecordFields) ->
- io:format("add_record_field ~p\n", [{Record, Field, RecordFields}]),
Name = element(2, Field),
Index = 1 + index_of_name_in_list(Name, RecordFields),
NewValue =
13 test/protobuffs_tests.erl
View
@@ -249,7 +249,7 @@ parse_extend_in_reserved_range_test_() ->
[?_assertEqual(out_of_range, Error)].
-should_encode_to_empty_test_() ->
+defaults_should_encode_to_empty_test_() ->
DataDir = "../test/erlang_protobuffs_SUITE_data",
Path = filename:absname(filename:join([DataDir,"hasdefault.proto"])),
ok = protobuffs_compile:scan_file(Path),
@@ -262,6 +262,17 @@ should_encode_to_empty_test_() ->
[?_assertEqual(<<>>, hasdefault_pb:encode_optionalwithdefault(R))
|| R <- [EncodeToEmpty1 | EncodeToEmpties]].
+empty_should_decode_to_defaults_test_() ->
+ DataDir = "../test/erlang_protobuffs_SUITE_data",
+ Path = filename:absname(filename:join([DataDir,"hasdefault.proto"])),
+ ok = protobuffs_compile:scan_file(Path),
+
+ RecordWithDefaults = {optionalwithdefault,
+ 1.0, 2.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ true, "test"},
+ [?_assertEqual(RecordWithDefaults,
+ hasdefault_pb:decode(optionalwithdefault, <<>>))].
+
absent_list_should_decode_to_nil_test_() ->
DataDir = "../test/erlang_protobuffs_SUITE_data",
Path = filename:absname(filename:join([DataDir,"addressbook.proto"])),
Please sign in to comment.
Something went wrong with that request. Please try again.