Skip to content

Commit 437192e

Browse files
committed
spec: For Int64, UInt64
1 parent f6ca9b2 commit 437192e

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

spec/binary_parser_spec.cr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ require "./spec_helper"
22
require "./fixture/*"
33

44
describe BinaryParser do
5+
describe "#uint64" do
6+
it "parse correct" do
7+
parser = UInt64Parser.new.load(UInt64Fixture)
8+
expect(parser.value).to eq(42)
9+
end
10+
end
11+
512
describe "#uint32" do
613
it "parse correct" do
714
parser = UInt32Parser.new.load(UInt32Fixture)
@@ -23,6 +30,13 @@ describe BinaryParser do
2330
end
2431
end
2532

33+
describe "#int64" do
34+
it "parse correct" do
35+
parser = Int64Parser.new.load(Int64Fixture)
36+
expect(parser.value).to eq(42)
37+
end
38+
end
39+
2640
describe "#int32" do
2741
it "parse correct" do
2842
parser = Int32Parser.new.load(Int32Fixture)

spec/fixture/int64.cr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "../../src/binary_parser"
2+
3+
class Int64Parser < BinaryParser
4+
int64 :value
5+
end
6+
7+
Int64Fixture = IO::Memory.new(sizeof(Int64))
8+
Int64Fixture.write_bytes(42i64)
9+
Int64Fixture.rewind

spec/fixture/uint64.cr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "../../src/binary_parser"
2+
3+
class UInt64Parser < BinaryParser
4+
uint64 :value
5+
end
6+
7+
UInt64Fixture = IO::Memory.new(sizeof(UInt64))
8+
UInt64Fixture.write_bytes(42u64)
9+
UInt64Fixture.rewind

0 commit comments

Comments
 (0)