-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
data_link_spec.rb
69 lines (53 loc) · 1.84 KB
/
data_link_spec.rb
1
2
3
4
5
6
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'spec_helper'
describe DataLink do
subject { described_class.new(0) }
it "should map datalink names to datalink layer type values" do
described_class.name_to_val(:en10mb).should == 1
end
it "should map datalink layer type values to datalink names" do
described_class.val_to_name(1).should == "EN10MB"
end
it "should be initialized from a pcap datalink value" do
subject.name.should == 'NULL'
end
it "should have a description" do
subject.description.should_not be_empty
end
describe "#initialize" do
it "should support initialization from a pcap datalink name Symbol" do
link = described_class.new(:null)
link.name.should == 'NULL'
end
it "should support initialization from a pcap datalink name String" do
link = described_class.new('en10mb')
link.name.should == 'EN10MB'
end
end
describe "#==" do
it "should allow equality comparison against numeric values" do
(subject == 0).should == true
(subject == 1).should == false
end
it "should allow equality comparison against String names" do
(subject == "null").should == true
(subject == "en10mb").should == false
end
it "should allow equality comparison against Symbol names" do
(subject == :null).should == true
(subject == :en10mb).should == false
end
it "should allow comparison against another described_class" do
(subject == described_class.new(0)).should == true
(subject == described_class.new(1)).should == false
end
it "should still compare correctly against any other object" do
(subject == Object.new).should == false
end
end
it "should convert to an Integer for the DLT value" do
subject.to_i.should == 0
end
it "should convert to a String for the DLT name" do
subject.to_s.should == 'NULL'
end
end