Sha256: d974ed1dfee74ad56bff864f95aeda5ce33dd3d83feee200930169873fcaf6ca

Contents?: true

Size: 1.35 KB

Versions: 188

Compression:

Stored size: 1.35 KB

Contents

require 'minitest/autorun'
require_relative 'linked_list'

class DequeTest < Minitest::Test
  def test_push_pop
    deque = Deque.new
    deque.push(10)
    deque.push(20)
    assert_equal 20, deque.pop
    assert_equal 10, deque.pop
  end

  def test_push_shift
    skip
    deque = Deque.new
    deque.push(10)
    deque.push(20)
    assert_equal 10, deque.shift
    assert_equal 20, deque.shift
  end

  def test_unshift_shift
    skip
    deque = Deque.new
    deque.unshift(10)
    deque.unshift(20)
    assert_equal 20, deque.shift
    assert_equal 10, deque.shift
  end

  def test_unshift_pop
    skip
    deque = Deque.new
    deque.unshift(10)
    deque.unshift(20)
    assert_equal 10, deque.pop
    assert_equal 20, deque.pop
  end

  def test_example
    skip
    deque = Deque.new
    deque.push(10)
    deque.push(20)
    assert_equal 20, deque.pop
    deque.push(30)
    assert_equal 10, deque.shift
    deque.unshift(40)
    deque.push(50)
    assert_equal 40, deque.shift
    assert_equal 50, deque.pop
    assert_equal 30, deque.shift
  end

  def test_pop_to_empty
    deque = Deque.new
    deque.push(10)
    assert_equal 10, deque.pop
    deque.push(20)
    assert_equal 20, deque.shift
  end

  def test_shift_to_empty
    deque = Deque.new
    deque.unshift(10)
    assert_equal 10, deque.shift
    deque.unshift(20)
    assert_equal 20, deque.pop
  end
end

Version data entries

188 entries across 188 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.97 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.96 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.95 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.94 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.93 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.92 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.91 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.90 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.89 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.88 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.87 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.86 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.85 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.84 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.83 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.82 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.81 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.80 tracks/ruby/exercises/linked-list/linked_list_test.rb
trackler-2.2.1.79 tracks/ruby/exercises/linked-list/linked_list_test.rb