Skip to content

Commit

Permalink
change AMQP codec field type 'b' interpretation
Browse files Browse the repository at this point in the history
from unsigned to signed, in compliance with the spec and most
clients.
  • Loading branch information
rade committed Mar 17, 2014
1 parent ec1a74f commit a640f74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rabbit_binary_generator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ field_value_to_binary(decimal, V) -> {Before, After} = V,
field_value_to_binary(timestamp, V) -> [$T, <<V:64>>];
field_value_to_binary(table, V) -> [$F | table_to_binary(V)];
field_value_to_binary(array, V) -> [$A | array_to_binary(V)];
field_value_to_binary(byte, V) -> [$b, <<V:8/unsigned>>];
field_value_to_binary(byte, V) -> [$b, <<V:8/signed>>];
field_value_to_binary(double, V) -> [$d, <<V:64/float>>];
field_value_to_binary(float, V) -> [$f, <<V:32/float>>];
field_value_to_binary(long, V) -> [$l, <<V:64/signed>>];
Expand Down
2 changes: 1 addition & 1 deletion src/rabbit_binary_parser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ parse_field_value(<<$F, VLen:32/unsigned, Table:VLen/binary, R/binary>>) ->
parse_field_value(<<$A, VLen:32/unsigned, Array:VLen/binary, R/binary>>) ->
{array, parse_array(Array), R};

parse_field_value(<<$b, V:8/unsigned, R/binary>>) -> {byte, V, R};
parse_field_value(<<$b, V:8/signed, R/binary>>) -> {byte, V, R};
parse_field_value(<<$d, V:64/float, R/binary>>) -> {double, V, R};
parse_field_value(<<$f, V:32/float, R/binary>>) -> {float, V, R};
parse_field_value(<<$l, V:64/signed, R/binary>>) -> {long, V, R};
Expand Down
4 changes: 2 additions & 2 deletions src/rabbit_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ test_table_codec() ->
{<<"table">>, table, [{<<"one">>, signedint, 54321},
{<<"two">>, longstr,
<<"A long string">>}]},
{<<"byte">>, byte, 255},
{<<"byte">>, byte, -128},
{<<"long">>, long, 1234567890},
{<<"short">>, short, 655},
{<<"bool">>, bool, true},
Expand All @@ -446,7 +446,7 @@ test_table_codec() ->
5,"table", "F", 31:32, % length of table
3,"one", "I", 54321:32,
3,"two", "S", 13:32, "A long string",
4,"byte", "b", 255:8,
4,"byte", "b", -128:8/signed,
4,"long", "l", 1234567890:64,
5,"short", "s", 655:16,
4,"bool", "t", 1,
Expand Down

0 comments on commit a640f74

Please sign in to comment.