2015-12-16 05:07:31 +00:00
|
|
|
# frozen_string_literal: false
|
2019-05-25 18:25:37 +09:00
|
|
|
|
|
|
|
require "test/unit"
|
|
|
|
require "rexml/document"
|
|
|
|
require "rexml/functions"
|
2010-09-18 08:34:37 +00:00
|
|
|
|
2014-05-27 12:07:40 +00:00
|
|
|
module REXMLTests
|
2019-05-25 18:25:37 +09:00
|
|
|
class TestFunctionsNumber < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
REXML::Functions.context = nil
|
|
|
|
end
|
2010-09-18 08:34:37 +00:00
|
|
|
|
2019-05-25 18:25:37 +09:00
|
|
|
def test_true
|
|
|
|
assert_equal(1, REXML::Functions.number(true))
|
2014-05-27 13:10:55 +00:00
|
|
|
end
|
2019-05-25 18:25:37 +09:00
|
|
|
|
|
|
|
def test_false
|
|
|
|
assert_equal(0, REXML::Functions.number(false))
|
2014-05-27 13:10:55 +00:00
|
|
|
end
|
2019-05-25 18:25:37 +09:00
|
|
|
|
|
|
|
def test_numeric
|
|
|
|
assert_equal(29, REXML::Functions.number(29))
|
2014-05-27 13:10:55 +00:00
|
|
|
end
|
2019-05-25 18:25:37 +09:00
|
|
|
|
|
|
|
def test_string_integer
|
|
|
|
assert_equal(100, REXML::Functions.number("100"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_string_float
|
|
|
|
assert_equal(-9.13, REXML::Functions.number("-9.13"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_node_set
|
|
|
|
root = REXML::Document.new("<root>100</root>").root
|
|
|
|
assert_equal(100, REXML::Functions.number([root]))
|
2014-05-27 13:10:55 +00:00
|
|
|
end
|
2010-09-18 08:34:37 +00:00
|
|
|
end
|
2014-05-27 10:21:10 +00:00
|
|
|
end
|