Permalink
Browse files

Added protobuf_generic test of hasdefaults.proto (Erlang-style defaul…

…ts).
  • Loading branch information...
1 parent d991b29 commit 2205a00f9c16141f2a96902b6fad82f459738a7a @esstrifork esstrifork committed Jun 30, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 test/protobuffs_generic_tests.erl
@@ -31,6 +31,26 @@ empty_test() ->
compile_pb("empty.proto"),
check_decode_loop(empty_pb, "empty.proto", 'Empty', DataGen, 100).
+
+default_test() ->
+ DataGen = fun() -> {withdefault,default(undefined, real()),
+ default(undefined, real()),
+ default(undefined, sint32()),
+ default(undefined, sint64()),
+ default(undefined, uint32()),
+ default(undefined, uint64()),
+ default(undefined, sint32()),
+ default(undefined, sint64()),
+ default(undefined, uint32()),
+ default(undefined, uint64()),
+ default(undefined, sint32()),
+ default(undefined, sint64()),
+ default(undefined, bool()),
+ default(undefined, string())}
+ end,
+ compile_pb("hasdefault.proto"),
+ check_decode_loop(hasdefault_pb, "hasdefault.proto", 'WithDefault', DataGen, 100).
+
%%====================
compile_pb(ProtoFile) ->
protobuffs_compile:scan_file(protofile_path(ProtoFile)).
@@ -47,6 +67,8 @@ check_decode(Module, ProtoFile, MsgName, Record) ->
Encoded = Module:encode(Record),
DecodedA = Module:decode(MsgNameLower, Encoded),
DecodedB = generic_decode_message(Encoded, ProtoFile, MsgName),
+ io:format(user, "DB| DecodedA=~p\n", [DecodedA]),
+ io:format(user, "DB| DecodedB=~p\n", [DecodedB]),
?assertEqual({a,DecodedA}, {a,DecodedB}).

0 comments on commit 2205a00

Please sign in to comment.