1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rexml/functions/test_number.rb
2019-08-04 11:55:49 +09:00

38 lines
820 B
Ruby

# frozen_string_literal: false
require "test/unit"
require "rexml/document"
require "rexml/functions"
module REXMLTests
class TestFunctionsNumber < Test::Unit::TestCase
def setup
REXML::Functions.context = nil
end
def test_true
assert_equal(1, REXML::Functions.number(true))
end
def test_false
assert_equal(0, REXML::Functions.number(false))
end
def test_numeric
assert_equal(29, REXML::Functions.number(29))
end
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]))
end
end
end