File: test_parse_options.rb

package info (click to toggle)
ruby-nokogiri 1.11.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,576 kB
  • sloc: xml: 28,086; ruby: 18,456; java: 13,067; ansic: 5,138; yacc: 265; sh: 208; makefile: 27
file content (70 lines) | stat: -rw-r--r-- 1,940 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require "helper"

module Nokogiri
  module XML
    class TestParseOptions < Nokogiri::TestCase
      def test_new
        options = Nokogiri::XML::ParseOptions.new
        assert_equal 0, options.options
      end

      def test_to_i
        options = Nokogiri::XML::ParseOptions.new
        assert_equal 0, options.to_i
      end

      ParseOptions.constants.each do |constant|
        next if constant == 'STRICT'
        class_eval %{
          def test_predicate_#{constant.downcase}
            options = ParseOptions.new(ParseOptions::#{constant})
            assert options.#{constant.downcase}?

            assert ParseOptions.new.#{constant.downcase}.#{constant.downcase}?
          end
        }
      end

      def test_strict_noent
        options = ParseOptions.new.recover.noent
        assert !options.strict?
      end

      def test_new_with_argument
        options = Nokogiri::XML::ParseOptions.new 1 << 1
        assert_equal 1 << 1, options.options
      end

      def test_unsetting
        options = Nokogiri::XML::ParseOptions.new Nokogiri::XML::ParseOptions::DEFAULT_HTML
        assert options.nonet?
        assert options.recover?
        options.nononet.norecover
        assert ! options.nonet?
        assert ! options.recover?
        options.nonet.recover
        assert options.nonet?
        assert options.recover?
      end

      def test_chaining
        options = Nokogiri::XML::ParseOptions.new.recover.noent
        assert options.recover?
        assert options.noent?
      end

      def test_inspect
        options = Nokogiri::XML::ParseOptions.new.recover.noent
        ins = options.inspect
        assert_match(/recover/, ins)
        assert_match(/noent/, ins)
      end

      def test_equality
        options = Nokogiri::XML::ParseOptions.new.recover.noent
        other = Nokogiri::XML::ParseOptions.new.recover.noent
        assert(options == other)
      end
    end
  end
end