Sha256: 42ef117cb223a0ef5615f03602db52921ad8982092d4d443abd0719592b0eec0

Contents?: true

Size: 1.65 KB

Versions: 5

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe DIY::Offline do
  
  it "should get next pcap" do
    files = [ "helper/gre.pcap", "helper/app.pcap" ]
    offline = DIY::Offline.new(files)
    offline.next_pcap
    lambda { offline.next_pcap }.should raise_error(DIY::EOFError)
  end
  
  it "should get next special first_pkt" do
    files = [ "helper/app.pcap", "helper/gre.pcap" ]
    offline = DIY::Offline.new(files)
    22.times { offline.nexts }
    offline.nexts.size.should == 1
  end
  
  it "should get nexts two" do
    files = [ "helper/gre.pcap", "helper/app.pcap" ]
    offline = DIY::Offline.new(files)
    offline.nexts.size.should == 1
    offline.nexts.size.should == 2
    offline.nexts.size.should == 2
    offline.next_pcap
    offline.nexts.size.should == 1
    offline.nexts.size.should == 7
    lambda { loop do offline.nexts end }.should raise_error(DIY::EOFError)
  end
  
  it "should get another two" do
    files = [ "helper/http.pcap", "helper/gre.pcap" ]
    offline = DIY::Offline.new(files)
    offline.nexts.size.should == 1
    offline.nexts.size.should == 1
    offline.nexts.size.should == 1
    #change to next
    offline.nexts.size.should == 1
    offline.nexts.size.should == 2
    offline.nexts.size.should == 2
    lambda { loop do offline.nexts end }.should raise_error(DIY::EOFError)
  end
  
  it "should open many files" do
      files = []
      600.times do
        files << "helper/http.pcap"
      end
      puts "files size = #{files.size}"
      offline = DIY::Offline.new(files)
      lambda {
      loop do
        offline.next_pcap
      end }.should raise_error(DIY::EOFError)
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
DIY-pcap-0.3.5 spec/offline_spec.rb
DIY-pcap-0.3.4 spec/offline_spec.rb
DIY-pcap-0.3.3 spec/offline_spec.rb
DIY-pcap-0.3.2 spec/offline_spec.rb
DIY-pcap-0.3.1 spec/offline_spec.rb