File: test_urinorm.rb

package info (click to toggle)
ruby-openid 2.5.0debian-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,980 kB
  • ctags: 2,219
  • sloc: ruby: 16,737; xml: 219; sh: 24; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 732 bytes parent folder | download
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
require "test/unit"
require "testutil"
require "openid/urinorm"

class URINormTestCase < Test::Unit::TestCase
  include OpenID::TestDataMixin

  def test_normalize
    lines = read_data_file('urinorm.txt')

    while lines.length > 0

      case_name = lines.shift.strip
      actual = lines.shift.strip
      expected = lines.shift.strip
      lines.shift #=> newline

      if expected == 'fail'
        begin
          OpenID::URINorm.urinorm(actual)
        rescue URI::InvalidURIError
          assert true
        else
          raise 'Should have gotten URI error'
        end
      else
        normalized = OpenID::URINorm.urinorm(actual)
        assert_equal(expected, normalized, case_name)
      end
    end
  end

end