Hi,
I have the following program written and when I run It comes up saying
zero tests.
what more should include in the code below for it to run in graphical
mode.
Please Help
require ‘test/unit/ui/tk/testrunner’
class Roman
MAX_ROMAN = 4999
def initialize(value)
if value <= 0 || value > MAX_ROMAN
fail "Roman values must be > 0 and <= #{MAX_ROMAN}"
end
@value = value
end
FACTORS = [["m", 1000], ["cm", 900], ["d", 500], ["cd", 400],
["c", 100], ["xc", 90], ["l", 50], ["xl", 40],
["x", 10],["ix" ,9], ["v", 5], ["iv", 4],
["i", 1]]
def to_s
value = @value
roman = "";
for code, factor in FACTORS
count, value = value.divmod(factor)
roman << (code * count)
end
roman
end
end
class TestRoman < Test::Unit::UI::Tk::TestRunner
def test_simple
assert_equal(“i”, Roman.new(1).to_s)
assert_equal(“ix”, Roman.new(9).to_s)
assert_equal(“ii”, Roman.new(2).to_s)
assert_equal(“iii”, Roman.new(3).to_s)
assert_equal(“iv”, Roman.new(4).to_s)
end
end
Thanks,
Navya.