Skip to content

Commit

Permalink
fixed more tests related to buffer lenght
Browse files Browse the repository at this point in the history
  • Loading branch information
priviterag committed Aug 14, 2015
1 parent 1cada14 commit cc90c94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/amq/protocol/table_value_encoder.rb
Expand Up @@ -91,7 +91,7 @@ def self.field_value_size(value)
when String then
acc += (value.bytesize + 4)
when Integer then
acc += 4
acc += 8
when Float then
acc += 8
when Time, DateTime then
Expand Down
12 changes: 6 additions & 6 deletions spec/amq/protocol/value_encoder_spec.rb
Expand Up @@ -22,7 +22,7 @@ module Protocol
end

it "calculates size of integer field values" do
expect(described_class.field_value_size(10)).to eq(5)
expect(described_class.field_value_size(10)).to eq(9)
expect(described_class.encode(10).bytesize).to eq(9)
end

Expand Down Expand Up @@ -67,12 +67,12 @@ module Protocol


input2 = { "intval" => 1 }
expect(described_class.field_value_size(input2)).to eq(17)
expect(described_class.field_value_size(input2)).to eq(21)
expect(described_class.encode(input2).bytesize).to eq(21)


input3 = { "intval" => 1, "key" => "value" }
expect(described_class.field_value_size(input3)).to eq(31)
expect(described_class.field_value_size(input3)).to eq(35)
expect(described_class.encode(input3).bytesize).to eq(35)
end

Expand All @@ -96,7 +96,7 @@ module Protocol
}
}

expect(described_class.field_value_size(input1)).to eq(162)
expect(described_class.field_value_size(input1)).to eq(166)
# puts(described_class.encode(input1).inspect)
expect(described_class.encode(input1).bytesize).to eq(166)

Expand All @@ -112,14 +112,14 @@ module Protocol
"hashval" => { "protocol" => "AMQP091", "true" => true, "false" => false, "nil" => nil }
}

expect(described_class.field_value_size(input2)).to eq(150)
expect(described_class.field_value_size(input2)).to eq(158)
expect(described_class.encode(input2).bytesize).to eq(158)
end

it "calculates size of basic array field values" do
input1 = [1, 2, 3]

expect(described_class.field_value_size(input1)).to eq(20)
expect(described_class.field_value_size(input1)).to eq(32)
expect(described_class.encode(input1).bytesize).to eq(32)


Expand Down

0 comments on commit cc90c94

Please sign in to comment.