~ubuntu-branches/ubuntu/dapper/ruby1.9/dapper

« back to all changes in this revision

Viewing changes to test/test_shellwords.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2006-05-08 22:23:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060508222312-w2wqeaz030ifi59j
Tags: 1.9.0+20060423-3ubuntu1
* Resynchronized with Debian.
* Only change from Debian is the addition of
  debian/patches/903_sparc_fix_define.patch to fix illegal instructions
  at runtime on sparc. (change from 1.9.0+20050921-1ubuntu1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
require 'shellwords'
 
3
 
 
4
class TestShellwords < Test::Unit::TestCase
 
5
 
 
6
  include Shellwords
 
7
 
 
8
  def setup
 
9
    @not_string = Class.new
 
10
    @cmd = "ruby my_prog.rb | less"
 
11
  end
 
12
 
 
13
 
 
14
  def test_string
 
15
    assert_instance_of(Array, shellwords(@cmd))
 
16
    assert_equal(4, shellwords(@cmd).length)
 
17
  end
 
18
  
 
19
  def test_unmatched_double_quote
 
20
    bad_cmd = 'one two "three'
 
21
    assert_raises ArgumentError do
 
22
      shellwords(bad_cmd)
 
23
    end
 
24
  end
 
25
  
 
26
  def test_unmatched_single_quote
 
27
    bad_cmd = "one two 'three"
 
28
    assert_raises ArgumentError do
 
29
      shellwords(bad_cmd)
 
30
    end
 
31
  end
 
32
  
 
33
  def test_unmatched_quotes
 
34
    bad_cmd = "one '"'"''""'""
 
35
    assert_raises ArgumentError do
 
36
      shellwords(bad_cmd)
 
37
    end
 
38
  end
 
39
end