File: uri_test.rb

package info (click to toggle)
ruby-citrus 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 3,417; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require File.expand_path('../../helper', __FILE__)
require 'citrus/grammars'

Citrus.require 'uri'

class UniformResourceIdentifierTest < Test::Unit::TestCase
  U = UniformResourceIdentifier

  def test_uri
    match = U.parse('http://www.example.com')
    assert(match)
  end

  def test_uri_with_query_string
    match = U.parse('http://www.example.com/?q=some+query')
    assert(match)
  end

  def test_authority
    match = U.parse('michael@', :root => :authority)
    assert(match)
  end

  def test_host
    match = U.parse('127.0.0.1', :root => :host)
    assert(match)

    match = U.parse('[12AD:34FC:A453:1922::]', :root => :host)
    assert(match)
  end

  def test_userinfo
    match = U.parse('michael', :root => :userinfo)
    assert(match)

    assert_raise(Citrus::ParseError) do
      U.parse('michael@', :root => :userinfo)
    end
  end

  def test_ipliteral
    match = U.parse('[12AD:34FC:A453:1922::]', :root => :'IP-literal')
    assert(match)
  end

  def test_ipvfuture
    match = U.parse('v1.123:456:789', :root => :IPvFuture)
    assert(match)

    match = U.parse('v5A.ABCD:1234', :root => :IPvFuture)
    assert(match)
  end
end