@@ -2,58 +2,92 @@ require "./spec_helper"
22require " ./fixture/*"
33
44describe BinaryParser do
5+ describe " #load" do
6+ it " load binary" do
7+ parser = UInt32Parser .new.load(UInt32Fixture )
8+ UInt32Fixture .rewind
9+
10+ expect(parser.value).to eq(42 )
11+ end
12+
13+ it " respect to IO::ByteFormat" do
14+ parser = UInt32Parser .new.load(BigEndianUInt32Fixture , IO ::ByteFormat ::BigEndian )
15+ BigEndianUInt32Fixture .rewind
16+
17+ expect(parser.value).to eq(42 )
18+ end
19+ end
20+
21+ describe " #endian" do
22+ it " work correct" do
23+ parser = BigEndianParser .new.load(BigEndianUInt32Fixture )
24+ BigEndianUInt32Fixture .rewind
25+
26+ expect(parser.value).to eq(42 )
27+ end
28+ end
29+
530 describe " #uint64" do
631 it " parse correct" do
732 parser = UInt64Parser .new.load(UInt64Fixture )
33+
834 expect(parser.value).to eq(42 )
935 end
1036 end
1137
1238 describe " #uint32" do
1339 it " parse correct" do
1440 parser = UInt32Parser .new.load(UInt32Fixture )
41+ UInt32Fixture .rewind
42+
1543 expect(parser.value).to eq(42 )
1644 end
1745 end
1846
1947 describe " #uint16" do
2048 it " parse correct" do
2149 parser = UInt16Parser .new.load(UInt16Fixture )
50+
2251 expect(parser.value).to eq(42 )
2352 end
2453 end
2554
2655 describe " #uint8" do
2756 it " parse correct" do
2857 parser = UInt8Parser .new.load(UInt8Fixture )
58+
2959 expect(parser.value).to eq(42 )
3060 end
3161 end
3262
3363 describe " #int64" do
3464 it " parse correct" do
3565 parser = Int64Parser .new.load(Int64Fixture )
66+
3667 expect(parser.value).to eq(42 )
3768 end
3869 end
3970
4071 describe " #int32" do
4172 it " parse correct" do
4273 parser = Int32Parser .new.load(Int32Fixture )
74+
4375 expect(parser.value).to eq(42 )
4476 end
4577 end
4678
4779 describe " #int16" do
4880 it " parse correct" do
4981 parser = Int16Parser .new.load(Int16Fixture )
82+
5083 expect(parser.value).to eq(42 )
5184 end
5285 end
5386
5487 describe " #int8" do
5588 it " parse correct" do
5689 parser = Int8Parser .new.load(Int8Fixture )
90+
5791 expect(parser.value).to eq(42 )
5892 end
5993 end
@@ -62,13 +96,15 @@ describe BinaryParser do
6296 context " when fixed length" do
6397 it " parse correct" do
6498 parser = FixedArrayParser .new.load(FixedArrayFixture )
99+
65100 expect(parser.arr).to eq([42 , 43 , 44 , 45 , 46 ])
66101 end
67102 end
68103
69104 context " when variable length" do
70105 it " parse correct" do
71106 parser = VarArrayParser .new.load(VarArrayFixture )
107+
72108 expect(parser.size).to eq(5 )
73109 expect(parser.arr).to eq([42 , 43 , 44 , 45 , 46 ])
74110 end
0 commit comments