Skip to content

Commit c8f1ab2

Browse files
committed
Increase test coverage for the recently added classes
1 parent 7d5ecad commit c8f1ab2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/dbus/marshall.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def do_parse(signature, mode: :plain)
102102
packet = data_class.from_raw(value, mode: mode)
103103
elsif data_class.basic?
104104
size = aligned_read_value(data_class.size_class)
105+
# @raw_msg.align(data_class.alignment)
106+
# ^ is not necessary because we've just read a suitably-aligned *size*
105107
value = @raw_msg.read(size)
106108
nul = @raw_msg.read(1)
107109
if nul != "\u0000"

spec/data_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@
183183

184184
include_examples "constructor accepts plain or typed values", good
185185
include_examples "constructor rejects values from this list", bad
186+
187+
describe ".alignment" do
188+
# this overly specific test avoids a redundant alignment call
189+
# in the production code
190+
it "returns the correct value" do
191+
expect(described_class.alignment).to eq 4
192+
end
193+
end
186194
end
187195

188196
describe DBus::Data::ObjectPath do
@@ -198,6 +206,14 @@
198206

199207
include_examples "constructor accepts plain or typed values", good
200208
include_examples "constructor rejects values from this list", bad
209+
210+
describe ".alignment" do
211+
# this overly specific test avoids a redundant alignment call
212+
# in the production code
213+
it "returns the correct value" do
214+
expect(described_class.alignment).to eq 4
215+
end
216+
end
201217
end
202218

203219
describe DBus::Data::Signature do
@@ -215,6 +231,14 @@
215231

216232
include_examples "constructor accepts plain or typed values", good
217233
include_examples "constructor rejects values from this list", bad
234+
235+
describe ".alignment" do
236+
# this overly specific test avoids a redundant alignment call
237+
# in the production code
238+
it "returns the correct value" do
239+
expect(described_class.alignment).to eq 1
240+
end
241+
end
218242
end
219243
end
220244

0 commit comments

Comments
 (0)