Sha256: a7750d319e9f05cde983e75ef92e16f95e711df58248051cd559ecc75c69c4e4

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
# Unit test for trepan.interface.user

require 'test/unit'
require_relative '../../interface/user'

# Tests Trepan::UserInterface
class TestInterfaceUser < Test::Unit::TestCase

  # Test UserInterface.confirm()
  def test_confirm
    
    user_intf = Trepan::UserInterface.new
    def user_intf.readline(prompt)
      $response_answer
    end

    ['y', 'Y', 'Yes', '  YES  '].each do |s|
      $response_answer = s
      ans = user_intf.confirm('Testing', true)
      assert_equal(true, ans)
    end
    
    ['n', 'N', 'No', '  NO  '].each do |s|
      $response_answer = s
      ans = user_intf.confirm('Testing', true)
      assert_equal(false, ans)
    end

    def user_intf.readline(prompt)
      raise EOFError
    end

    [true, false].each do |tf|
      assert_equal(tf, user_intf.confirm('default testing', tf))
    end

    # Ok, we'll throw in one test of EOFError
    assert_raises EOFError do 
      user_intf.readline('')
    end

  end
  # FIXME: more thorough testing of other routines in user.
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trepanning-2.15.35 test/unit/test-intf-user.rb
trepanning-1.93.35 test/unit/test-intf-user.rb
trepanning-2.15.33 test/unit/test-intf-user.rb
trepanning-1.93.32 test/unit/test-intf-user.rb
trepanning-0.1.6 test/unit/test-intf-user.rb
trepanning-0.1.4 test/unit/test-intf-user.rb
trepanning-0.1.3 test/unit/test-intf-user.rb
trepanning-0.1.2 test/unit/test-intf-user.rb
trepanning-0.1.1 test/unit/test-intf-user.rb
trepanning-0.1.0 test/unit/test-intf-user.rb
trepanning-0.0.9 test/unit/test-intf-user.rb
trepanning-0.0.8 test/unit/test-intf-user.rb
trepanning-0.0.6 test/unit/test-intf-user.rb
trepanning-0.0.4 test/unit/test-intf-user.rb