From 6ef82943978ea5816a91c32e9ff822c73d1935f9 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Sat, 25 May 2019 17:06:53 +0900 Subject: [ruby/rexml] xpath: fix a bug for equality or relational expressions GitHub: fix #17 There is a bug when they are used against node set. They should return boolean value but they returned node set. Reported by Mirko Budszuhn. Thanks!!! https://github.com/ruby/rexml/commit/a02bf38440 --- test/rexml/xpath/test_node_set.rb | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test/rexml/xpath/test_node_set.rb (limited to 'test/rexml/xpath/test_node_set.rb') diff --git a/test/rexml/xpath/test_node_set.rb b/test/rexml/xpath/test_node_set.rb new file mode 100644 index 0000000000..77f26f7a6d --- /dev/null +++ b/test/rexml/xpath/test_node_set.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: false + +require_relative "../rexml_test_utils" + +require "rexml/document" + +module REXMLTests + class TestXPathNodeSet < Test::Unit::TestCase + def match(xml, xpath) + document = REXML::Document.new(xml) + REXML::XPath.match(document, xpath) + end + + def test_boolean_true + xml = <<-XML + + + + + + XML + assert_equal([true], + match(xml, "/root/child=true()")) + end + + def test_boolean_false + xml = <<-XML + + + + XML + assert_equal([false], + match(xml, "/root/child=true()")) + end + + def test_number_true + xml = <<-XML + + + 100 + 200 + + XML + assert_equal([true], + match(xml, "/root/child=100")) + end + + def test_number_false + xml = <<-XML + + + 100 + 200 + + XML + assert_equal([false], + match(xml, "/root/child=300")) + end + + def test_string_true + xml = <<-XML + + + text + string + + XML + assert_equal([true], + match(xml, "/root/child='string'")) + end + + def test_string_false + xml = <<-XML + + + text + string + + XML + assert_equal([false], + match(xml, "/root/child='nonexistent'")) + end + end +end -- cgit v1.2.3