Permalink
Browse files

Fixed bool's to be properly deserialized into true and false atoms.

  • Loading branch information...
1 parent 679f304 commit 986dfb0c3e60c1e8dbe78f5c13794841cfaa5e63 @djnym djnym committed Nov 27, 2009
Showing with 11 additions and 2 deletions.
  1. +2 −0 ChangeLog
  2. +5 −0 src/protobuffs.erl
  3. +4 −2 tests/protobuffs_t_003.t
View
@@ -1,3 +1,5 @@
* Thu Dec 03 2009 Anthony Molinaro <anthony.molinaro@openx.org> 0.0.1
- Fixed path for unit tests
- Have .gitignore ignore all generated files
+- Fixed bool type, they were being improperly left as 0 and 1 instead of using
+the true and false atoms
View
@@ -149,6 +149,11 @@ typecast(Value, SignedType) when SignedType =:= int32; SignedType =:= int64 ->
end;
typecast(Value, SignedType) when SignedType =:= sint32; SignedType =:= sint64 ->
(Value bsr 1) bxor (-(Value band 1));
+typecast(Value, Type) when Type =:= bool ->
+ case Value of
+ 1 -> true;
+ _ -> false
+ end;
typecast(Value, _) ->
Value.
View
@@ -3,7 +3,7 @@
%%! -pa ../src -noshell
main(_) ->
- etap:plan(18),
+ etap:plan(20),
Tests = [
{8, uint32},
{16, uint32},
@@ -22,7 +22,9 @@ main(_) ->
{<<"It's a secret to everyone.">>, string},
{<<4,8,15,16,23,42>>, bytes},
{3.141592025756836, float},
- {1.00000000000000022204460492503130808472633361816406, double}
+ {1.00000000000000022204460492503130808472633361816406, double},
+ {false, bool},
+ {true, bool}
],
lists:foreach(
fun(Test) ->

0 comments on commit 986dfb0

Please sign in to comment.