Sha256: d73fe79c951eae482dacc286d9628419a2011ffb09f5cb5104654f21aad04f7d

Contents?: true

Size: 809 Bytes

Versions: 11

Compression:

Stored size: 809 Bytes

Contents

require_relative 'test_helper'

describe Adrian::CompositeQueue do
  before do
    @q1 = Adrian::ArrayQueue.new
    @q2 = Adrian::ArrayQueue.new
    @q  = Adrian::CompositeQueue.new(@q1, @q2)
  end

  describe "popping" do
    it 'should return nil when all queues are empty' do
      @q.pop.must_be_nil
    end

    it 'should return an item from the first queue that has items' do
      @q1.push(1)
      @q1.push(2)
      @q2.push(3)
      @q2.push(4)

      @q.pop.value.must_equal(1)
      @q.pop.value.must_equal(2)
      @q.pop.value.must_equal(3)
      @q.pop.value.must_equal(4)
      @q.pop.must_be_nil
      @q1.pop.must_be_nil
      @q2.pop.must_be_nil
    end
  end

  describe "pushing" do
    it "should not be allowed" do
      lambda { @q.push(1) }.must_raise(RuntimeError)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
adrian-1.4.0 test/composite_queue_test.rb
adrian-1.3.3 test/composite_queue_test.rb
adrian-1.3.2 test/composite_queue_test.rb
adrian-1.3.1 test/composite_queue_test.rb
adrian-1.3.0 test/composite_queue_test.rb
adrian-1.2.0 test/composite_queue_test.rb
adrian-1.1.2 test/composite_queue_test.rb
adrian-1.1.1 test/composite_queue_test.rb
adrian-1.1.0 test/composite_queue_test.rb
adrian-1.0.1 test/composite_queue_test.rb
adrian-1.0.0 test/composite_queue_test.rb