riddle 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,11 +23,11 @@ module Riddle
23
23
 
24
24
  # Append an integer
25
25
  def append_int(int)
26
- @message << [int].pack('N')
26
+ @message << [int.to_i].pack('N')
27
27
  end
28
28
 
29
29
  def append_64bit_int(int)
30
- @message << [int >> 32, int & 0xFFFFFFFF].pack('NN')
30
+ @message << [int.to_i >> 32, int.to_i & 0xFFFFFFFF].pack('NN')
31
31
  end
32
32
 
33
33
  # Append a float
@@ -67,4 +67,4 @@ module Riddle
67
67
  end
68
68
  end
69
69
  end
70
- end
70
+ end
@@ -22,7 +22,37 @@ describe Riddle::Client::Message do
22
22
  it "should append integers correctly - packed with N" do
23
23
  message = Riddle::Client::Message.new
24
24
  message.append_int 234
25
- message.to_s.should == [234].pack('N')
25
+ message.to_s.should == "\x00\x00\x00\xEA"
26
+ end
27
+
28
+ it "should append integers as strings correctly - packed with N" do
29
+ message = Riddle::Client::Message.new
30
+ message.append_int "234"
31
+ message.to_s.should == "\x00\x00\x00\xEA"
32
+ end
33
+
34
+ it "should append 64bit integers correctly" do
35
+ message = Riddle::Client::Message.new
36
+ message.append_64bit_int 234
37
+ message.to_s.should == "\x00\x00\x00\x00\x00\x00\x00\xEA"
38
+ end
39
+
40
+ it "should append 64bit integers that use exactly 32bits correctly" do
41
+ message = Riddle::Client::Message.new
42
+ message.append_64bit_int 4294967295
43
+ message.to_s.should == "\x00\x00\x00\x00\xFF\xFF\xFF\xFF"
44
+ end
45
+
46
+ it "should append 64bit integers that use more than 32 bits correctly" do
47
+ message = Riddle::Client::Message.new
48
+ message.append_64bit_int 4294967296
49
+ message.to_s.should == "\x00\x00\x00\x01\x00\x00\x00\x00"
50
+ end
51
+
52
+ it "should append 64bit integers as strings correctly" do
53
+ message = Riddle::Client::Message.new
54
+ message.append_64bit_int "234"
55
+ message.to_s.should == "\x00\x00\x00\x00\x00\x00\x00\xEA"
26
56
  end
27
57
 
28
58
  it "should append floats correctly - packed with f" do
@@ -60,4 +90,4 @@ describe Riddle::Client::Message do
60
90
  message.to_s.should == [4, 4].pack('NN') + "test" + [2, 3].pack('NN') +
61
91
  "one" + [3].pack('N') + "two" + [1.5, 1.7].pack('ff').unpack('L*L*').pack('NN')
62
92
  end
63
- end
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-10 00:00:00 +11:00
12
+ date: 2010-01-29 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency