spec/system_spec.rb in bindata-1.4.1 vs spec/system_spec.rb in bindata-1.4.2
- old
+ new
@@ -340,5 +340,25 @@
str = "\x00\x00\x00\x00\x05"
CustomIntRecord.read(str).should == {"a" => 5}
end
end
+describe BinData::Primitive, "representing a string" do
+ class PascalStringPrimitive < BinData::Primitive
+ uint8 :len, :value => lambda { data.length }
+ string :data, :read_length => :len
+
+ def get; self.data; end
+ def set(v) self.data = v; end
+ end
+
+ subject { PascalStringPrimitive.new("testing") }
+
+ it "should compare to regexp" do
+ (subject =~ /es/).should == 1
+ end
+
+ it "should compare to regexp" do
+ (/es/ =~ subject).should == 1
+ end
+end
+