packetfu 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -12
- data/bench/octets.rb +9 -9
- data/examples/100kpackets.rb +13 -12
- data/examples/ackscan.rb +17 -16
- data/examples/arp.rb +36 -35
- data/examples/arphood.rb +37 -36
- data/examples/dissect_thinger.rb +7 -6
- data/examples/ethernet.rb +1 -0
- data/examples/examples.rb +1 -0
- data/examples/ifconfig.rb +1 -0
- data/examples/new-simple-stats.rb +24 -23
- data/examples/packetfu-shell.rb +26 -25
- data/examples/simple-sniffer.rb +10 -9
- data/examples/simple-stats.rb +24 -23
- data/examples/slammer.rb +4 -3
- data/lib/packetfu.rb +128 -127
- data/lib/packetfu/capture.rb +170 -169
- data/lib/packetfu/config.rb +53 -52
- data/lib/packetfu/inject.rb +57 -56
- data/lib/packetfu/packet.rb +529 -528
- data/lib/packetfu/pcap.rb +580 -579
- data/lib/packetfu/protos/arp.rb +91 -90
- data/lib/packetfu/protos/arp/header.rb +159 -158
- data/lib/packetfu/protos/arp/mixin.rb +37 -36
- data/lib/packetfu/protos/eth.rb +45 -44
- data/lib/packetfu/protos/eth/header.rb +244 -243
- data/lib/packetfu/protos/eth/mixin.rb +4 -3
- data/lib/packetfu/protos/hsrp.rb +70 -69
- data/lib/packetfu/protos/hsrp/header.rb +108 -107
- data/lib/packetfu/protos/hsrp/mixin.rb +30 -29
- data/lib/packetfu/protos/icmp.rb +72 -71
- data/lib/packetfu/protos/icmp/header.rb +83 -82
- data/lib/packetfu/protos/icmp/mixin.rb +15 -14
- data/lib/packetfu/protos/invalid.rb +50 -49
- data/lib/packetfu/protos/ip.rb +70 -69
- data/lib/packetfu/protos/ip/header.rb +292 -291
- data/lib/packetfu/protos/ip/mixin.rb +41 -40
- data/lib/packetfu/protos/ipv6.rb +51 -50
- data/lib/packetfu/protos/ipv6/header.rb +189 -188
- data/lib/packetfu/protos/ipv6/mixin.rb +30 -29
- data/lib/packetfu/protos/lldp.rb +3 -1
- data/lib/packetfu/protos/lldp/header.rb +1 -0
- data/lib/packetfu/protos/lldp/mixin.rb +1 -0
- data/lib/packetfu/protos/tcp.rb +177 -176
- data/lib/packetfu/protos/tcp/ecn.rb +36 -35
- data/lib/packetfu/protos/tcp/flags.rb +75 -74
- data/lib/packetfu/protos/tcp/header.rb +269 -268
- data/lib/packetfu/protos/tcp/hlen.rb +33 -32
- data/lib/packetfu/protos/tcp/mixin.rb +47 -46
- data/lib/packetfu/protos/tcp/option.rb +322 -321
- data/lib/packetfu/protos/tcp/options.rb +96 -95
- data/lib/packetfu/protos/tcp/reserved.rb +36 -35
- data/lib/packetfu/protos/udp.rb +117 -116
- data/lib/packetfu/protos/udp/header.rb +92 -91
- data/lib/packetfu/protos/udp/mixin.rb +4 -3
- data/lib/packetfu/structfu.rb +281 -280
- data/lib/packetfu/utils.rb +211 -208
- data/lib/packetfu/version.rb +42 -41
- data/packetfu.gemspec +1 -1
- data/spec/ethpacket_spec.rb +48 -48
- data/spec/packet_spec.rb +57 -57
- data/spec/packet_subclasses_spec.rb +8 -8
- data/spec/packetfu_spec.rb +59 -59
- data/spec/structfu_spec.rb +268 -268
- data/spec/tcp_spec.rb +75 -75
- data/test/all_tests.rb +13 -13
- data/test/func_lldp.rb +3 -3
- data/test/ptest.rb +2 -2
- data/test/test_arp.rb +116 -116
- data/test/test_capture.rb +45 -45
- data/test/test_eth.rb +68 -68
- data/test/test_hsrp.rb +9 -9
- data/test/test_icmp.rb +52 -52
- data/test/test_inject.rb +18 -18
- data/test/test_invalid.rb +16 -16
- data/test/test_ip.rb +36 -36
- data/test/test_ip6.rb +48 -48
- data/test/test_octets.rb +21 -21
- data/test/test_packet.rb +154 -154
- data/test/test_pcap.rb +170 -170
- data/test/test_structfu.rb +97 -97
- data/test/test_tcp.rb +320 -320
- data/test/test_udp.rb +76 -76
- metadata +2 -2
data/test/test_pcap.rb
CHANGED
@@ -4,205 +4,205 @@ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
|
|
4
4
|
require 'packetfu'
|
5
5
|
|
6
6
|
class PcapHeaderTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
7
|
+
include PacketFu
|
8
|
+
def setup
|
9
|
+
@file = File.open('sample.pcap') {|f| f.read}
|
10
|
+
@file.force_encoding "binary" if @file.respond_to? :force_encoding
|
11
|
+
@file_magic = @file[0,4]
|
12
|
+
@file_header = @file[0,24]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_header_size
|
16
|
+
assert_equal(24, PcapHeader.new.sz)
|
17
|
+
assert_equal(24, PcapHeader.new.sz)
|
18
|
+
end
|
19
|
+
|
20
|
+
# If this fails, the rest is pretty much for naught.
|
21
|
+
def test_read_file
|
22
|
+
assert_equal("\xd4\xc3\xb2\xa1", @file_magic) # yep, it's libpcap.
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_endian_magic
|
26
|
+
p = PcapHeader.new # usual case
|
27
|
+
assert_equal(@file_magic, p.to_s[0,4])
|
28
|
+
p = PcapHeader.new(:endian => :big)
|
29
|
+
assert_equal("\xa1\xb2\xc3\xd4", p.to_s[0,4])
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_header
|
33
|
+
p = PcapHeader.new
|
34
|
+
assert_equal(@file_header, p.to_s[0,24])
|
35
|
+
p = PcapHeader.new(:endian => :big)
|
36
|
+
assert_not_equal(@file_header, p.to_s[0,24])
|
37
|
+
# We want to ensure our endianness is little or big.
|
38
|
+
assert_raise(ArgumentError) {PcapHeader.new(:endian => :just_right)}
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_header_read
|
42
|
+
p = PcapHeader.new
|
43
|
+
p.read @file
|
44
|
+
assert_equal(@file_header,p.to_s)
|
45
|
+
end
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
49
|
class TimestampTest < Test::Unit::TestCase
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
50
|
+
include PacketFu
|
51
|
+
def setup
|
52
|
+
@file = File.open('sample.pcap') {|f| f.read}
|
53
|
+
@ts = @file[24,8]
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_timestamp_size
|
57
|
+
assert_equal(3, Timestamp.new.size) # Number of elements
|
58
|
+
assert_equal(8, Timestamp.new.sz) # Length of the string (in PacketFu)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_timestamp_read
|
62
|
+
t = Timestamp.new
|
63
|
+
t.read(@ts)
|
64
|
+
assert_equal(@ts, t.to_s)
|
65
|
+
end
|
66
66
|
end
|
67
67
|
|
68
68
|
class PcapPacketTest < Test::Unit::TestCase
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
include PacketFu
|
70
|
+
def setup
|
71
|
+
@file = File.open('sample.pcap') {|f| f.read}
|
72
|
+
@file.force_encoding "binary" if @file.respond_to? :force_encoding
|
73
|
+
@header = @file[0,24]
|
74
|
+
@packet = @file[24,100] # pkt is 78 bytes + 16 bytes pcap hdr == 94
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_pcappacket_read
|
78
|
+
p = PcapPacket.new :endian => :little
|
79
|
+
p.read(@packet)
|
80
|
+
assert_equal(78,@packet[8,4].unpack("V").first)
|
81
|
+
assert_equal(@packet[8,4].unpack("V").first,p[:incl_len].to_i)
|
82
|
+
assert_equal(@packet[0,94],p.to_s)
|
83
|
+
end
|
84
84
|
|
85
85
|
end
|
86
86
|
|
87
87
|
class PcapPacketsTest < Test::Unit::TestCase
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
include PacketFu
|
90
|
+
def setup
|
91
|
+
@file = File.open('sample.pcap') {|f| f.read}
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
def test_pcappackets_read
|
95
|
+
p = PcapPackets.new
|
96
|
+
p.read @file
|
97
|
+
assert_equal(11,p.size)
|
98
|
+
assert_equal(@file[24,@file.size],p.to_s)
|
99
|
+
end
|
100
100
|
|
101
101
|
end
|
102
102
|
|
103
103
|
class PcapFileTest < Test::Unit::TestCase
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
104
|
+
require 'digest/md5'
|
105
|
+
|
106
|
+
include PacketFu
|
107
|
+
def setup
|
108
|
+
@file = File.open('sample.pcap') {|f| f.read}
|
109
|
+
@md5 = '1be3b5082bb135c6f22de8801feb3495'
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_pcapfile_read
|
113
|
+
p = PcapFile.new
|
114
|
+
p.read @file
|
115
|
+
assert_equal(3,p.size)
|
116
|
+
assert_equal(@file.size, p.sz)
|
117
|
+
assert_equal(@file, p.to_s)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_pcapfile_file_to_array
|
121
|
+
p = PcapFile.new.file_to_array(:filename => 'sample.pcap')
|
122
|
+
assert_equal(@md5.downcase, Digest::MD5.hexdigest(@file).downcase)
|
123
|
+
assert_instance_of(Array, p)
|
124
|
+
assert_instance_of(String, p[0])
|
125
|
+
assert_equal(11,p.size)
|
126
|
+
assert_equal(78,p[0].size)
|
127
|
+
assert_equal(94,p[1].size)
|
128
|
+
assert_equal(74,p[10].size)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_pcapfile_read_and_write
|
132
|
+
File.unlink('out.pcap') if File.exists? 'out.pcap'
|
133
|
+
p = PcapFile.new
|
134
|
+
p.read @file
|
135
|
+
p.to_file(:filename => 'out.pcap')
|
136
|
+
@newfile = File.open('out.pcap') {|f| f.read(f.stat.size)}
|
137
|
+
@newfile.force_encoding "binary" if @newfile.respond_to? :force_encoding
|
138
|
+
assert_equal(@file, @newfile)
|
139
|
+
p.to_file(:filename => 'out.pcap', :append => true)
|
140
|
+
packet_array = PcapFile.new.f2a(:filename => 'out.pcap')
|
141
|
+
assert_equal(22, packet_array.size)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_pcapfile_write_after_recalc
|
145
|
+
File.unlink('out.pcap') if File.exists? 'out.pcap'
|
146
|
+
pcaps = PcapFile.new.file_to_array(:filename => 'sample.pcap')
|
147
|
+
pcaps.each {|pkt|
|
148
|
+
p = Packet.parse pkt
|
149
|
+
p.recalc
|
150
|
+
p.to_f('out.pcap','a')
|
151
|
+
}
|
152
|
+
packet_array = PcapFile.new.f2a(:filename => 'out.pcap')
|
153
|
+
assert_equal(11, packet_array.size)
|
154
|
+
File.unlink('out.pcap')
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_pcapfile_read_and_write_timestamps
|
158
|
+
File.unlink('out.pcap') if File.exists? 'out.pcap'
|
159
|
+
pf = PcapFile.new
|
160
|
+
arr = pf.file_to_array(:filename => 'sample.pcap')
|
161
|
+
assert_equal(11, arr.size)
|
162
|
+
pf = PcapFile.new
|
163
|
+
pf.a2f(:array => arr, :f => 'out.pcap', :ts_inc => 4,
|
164
|
+
:timestamp => Time.now.to_i - 1_000_000)
|
165
|
+
diff_time = pf.body[0].timestamp.sec.to_i - pf.body[1].timestamp.sec.to_i
|
166
|
+
assert_equal(-4, diff_time)
|
167
|
+
File.unlink('out.pcap')
|
168
|
+
end
|
169
169
|
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
# Test the legacy Read objects.
|
173
173
|
class ReadTest < Test::Unit::TestCase
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
175
|
+
include PacketFu
|
176
|
+
|
177
|
+
def test_read_string
|
178
|
+
pkts = Read.file_to_array(:file => 'sample.pcap')
|
179
|
+
assert_kind_of Array, pkts
|
180
|
+
assert_equal 11, pkts.size
|
181
|
+
this_packet = Packet.parse pkts[0]
|
182
|
+
assert_kind_of UDPPacket, this_packet
|
183
|
+
that_packet = Packet.parse pkts[3]
|
184
|
+
assert_kind_of ICMPPacket, that_packet
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_read_hash
|
188
|
+
pkts = Read.file_to_array(:file => 'sample.pcap', :ts => true)
|
189
|
+
assert_kind_of Array, pkts
|
190
|
+
assert_equal 11, pkts.size
|
191
|
+
this_packet = Packet.parse pkts[0].values.first
|
192
|
+
assert_kind_of UDPPacket, this_packet
|
193
|
+
that_packet = Packet.parse pkts[3].values.first
|
194
|
+
assert_kind_of ICMPPacket, that_packet
|
195
|
+
end
|
196
196
|
|
197
197
|
end
|
198
198
|
|
199
199
|
class WriteTest < Test::Unit::TestCase
|
200
200
|
|
201
|
-
|
201
|
+
include PacketFu
|
202
202
|
|
203
|
-
|
203
|
+
def test_write
|
204
204
|
|
205
|
-
|
205
|
+
end
|
206
206
|
|
207
207
|
end
|
208
208
|
|
data/test/test_structfu.rb
CHANGED
@@ -5,107 +5,107 @@ require 'packetfu'
|
|
5
5
|
|
6
6
|
# Whee unit testing.
|
7
7
|
class IntStringTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
8
|
+
include StructFu
|
9
|
+
|
10
|
+
def test_intstring_len
|
11
|
+
s = IntString.new("hello!", Int32)
|
12
|
+
assert_equal(s.len, s.int.v)
|
13
|
+
assert_not_equal(s.len, s.length)
|
14
|
+
s.len=10
|
15
|
+
assert_equal(s.len, s[:int][:value])
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_intstring_to_s
|
19
|
+
s = IntString.new("hello!", Int16)
|
20
|
+
assert_equal("\x00\x06hello!",s.to_s)
|
21
|
+
s.len=10
|
22
|
+
assert_equal("\x00\x0ahello!",s.to_s)
|
23
|
+
s = IntString.new("hello!", Int16, :parse)
|
24
|
+
s.len=10
|
25
|
+
assert_equal("\x00\x0ahello!\x00\x00\x00\x00",s.to_s)
|
26
|
+
s = IntString.new("hello!", Int16, :fix)
|
27
|
+
s.len=10
|
28
|
+
assert_equal("\x00\x06hello!",s.to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_intstring_new
|
32
|
+
assert_equal("\x06Hello!",IntString.new("Hello!").to_s)
|
33
|
+
assert_equal("\x00\x06Hello!",IntString.new("Hello!",Int16).to_s)
|
34
|
+
assert_equal("\x06\x00\x00\x00Hello!",IntString.new("Hello!",Int32le).to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_intstring_read
|
38
|
+
s = IntString.new
|
39
|
+
s.read("\x06Hello!")
|
40
|
+
assert_equal("Hello!", s.string)
|
41
|
+
assert_equal("Hello!", s[:string])
|
42
|
+
assert_equal(6, s.int.value)
|
43
|
+
assert_equal(6, s.len)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_intstring_parse
|
47
|
+
s = IntString.new
|
48
|
+
s[:mode] = :parse
|
49
|
+
s.parse("\x02Hello!")
|
50
|
+
assert_equal("He", s.string)
|
51
|
+
assert_equal(2, s.int.v)
|
52
|
+
s.parse("\x0aHello!")
|
53
|
+
assert_equal("Hello!\x00\x00\x00\x00", s.string)
|
54
|
+
s[:mode] = :fix
|
55
|
+
s.parse("\x0aHello!")
|
56
|
+
assert_equal("Hello!", s.string)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_intstring_nocalc
|
60
|
+
s = IntString.new
|
61
|
+
s[:string] = "Hello"
|
62
|
+
assert_equal(0,s.int.value)
|
63
|
+
end
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
67
|
class IntTest < Test::Unit::TestCase
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
68
|
+
include StructFu
|
69
|
+
|
70
|
+
def test_int_to_s
|
71
|
+
assert_equal("\x02",Int8.new(2).to_s)
|
72
|
+
assert_equal("\x00\x07",Int16.new(7).to_s)
|
73
|
+
assert_equal("\x00\x00\x00\x0a",Int32.new(10).to_s)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_int_big
|
77
|
+
assert_equal("\x00\x07",Int16be.new(7).to_s)
|
78
|
+
assert_equal("\x00\x00\x00\x0a",Int32be.new(10).to_s)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_int_little
|
82
|
+
assert_equal("\x07\x00",Int16le.new(7).to_s)
|
83
|
+
assert_equal("\x01\x04\x00\x00",Int32le.new(1025).to_s)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_read
|
87
|
+
assert_equal(7,Int16.new.read("\x00\x07").to_i)
|
88
|
+
assert_equal(Int32.new.read("\x00\x00\x00\x0a").to_i,10)
|
89
|
+
i = Int32.new
|
90
|
+
i.read("\x00\x00\x00\xff")
|
91
|
+
assert_equal(i.v, 255)
|
92
|
+
assert_equal(7, Int16le.new.read("\x07\x00").to_i)
|
93
|
+
assert_equal(1025,Int32le.new.read("\x01\x04\x00\x00").to_i)
|
94
|
+
i = Int32le.new
|
95
|
+
i.read("\xff\x00\x00\x00")
|
96
|
+
assert_equal(i.v, 255)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_int_compare
|
100
|
+
little = Int32le.new
|
101
|
+
big = Int32be.new
|
102
|
+
little.v = 128
|
103
|
+
big.v = 0x80
|
104
|
+
assert_not_equal(little.to_s, big.to_s)
|
105
|
+
assert_equal(little.v, big.v)
|
106
|
+
assert_equal(little[:value], big[:value])
|
107
|
+
assert_equal(little.value, big.value)
|
108
|
+
end
|
109
109
|
|
110
110
|
end
|
111
111
|
|