D
dkmd_nielsen
I have test case that is failing.
===============================================================
1) Failure: testProj(TestProject) [---------\TestProject.rb:26]:
<"068906"> expected but was <"68906">.
1 tests, 1 assertions, 1 failures, 0 errors
===============================================================
In the assignment of the class variable value, the first assert_equal
test case appears to be comparing the expected value to the input of
the class variable assignment...not the value returned by the
assigment. The two asserts that follow the first yield the correct
result, so I know the assignment of the class variable is correct. Any
suggestions as to what I might be doing wrong in the first assert?
===============================================================
Given the following in my test case:
===============================================================
class TestProject < Test::Unit::TestCase
def setup
@prj=Project.new # new project
end
def testProj
assert_equal('068906',@prj.proj='68906')
assert_equal(true,@prj.proj=='068906')
assert_equal(false,@prj.proj=='68906')
end
end
===============================================================
And given the following function being called to assign the value of
the class variable.
===============================================================
# Set the project number. # Project number gets tranlated to the
# format "nnnnnn", and is zero filled. Note: while zero filling is
# the proper display of the project number, it does cause problems
# when trying to find folder names.
def proj=(num)
if num.class == String
raise ArgumentError,"Project number #{num} must be in the form
<#>nnnnnn" if num !~/#*(\d{1,6})/
n = $1.to_i
elsif num.class == Fixnum
n = num
elsif num.class == Float
n = num.to_i
else
raise ArgumentError,"Project number #{num} is in an
unrecognizable format"
end
@proj = sprintf("%06d",n)
end
===============================================================
The following test case does work
1 tests, 2 assertions, 0 failures, 0 errors
===============================================================
def testProj
@prj.proj='68906'
# assert_equal("068906",@prj.proj='68906')
assert_equal(true,@prj.proj=='068906')
assert_equal(false,@prj.proj=='68906')
end
Your time, as always, is appreciated...
dvn
===============================================================
1) Failure: testProj(TestProject) [---------\TestProject.rb:26]:
<"068906"> expected but was <"68906">.
1 tests, 1 assertions, 1 failures, 0 errors
===============================================================
In the assignment of the class variable value, the first assert_equal
test case appears to be comparing the expected value to the input of
the class variable assignment...not the value returned by the
assigment. The two asserts that follow the first yield the correct
result, so I know the assignment of the class variable is correct. Any
suggestions as to what I might be doing wrong in the first assert?
===============================================================
Given the following in my test case:
===============================================================
class TestProject < Test::Unit::TestCase
def setup
@prj=Project.new # new project
end
def testProj
assert_equal('068906',@prj.proj='68906')
assert_equal(true,@prj.proj=='068906')
assert_equal(false,@prj.proj=='68906')
end
end
===============================================================
And given the following function being called to assign the value of
the class variable.
===============================================================
# Set the project number. # Project number gets tranlated to the
# format "nnnnnn", and is zero filled. Note: while zero filling is
# the proper display of the project number, it does cause problems
# when trying to find folder names.
def proj=(num)
if num.class == String
raise ArgumentError,"Project number #{num} must be in the form
<#>nnnnnn" if num !~/#*(\d{1,6})/
n = $1.to_i
elsif num.class == Fixnum
n = num
elsif num.class == Float
n = num.to_i
else
raise ArgumentError,"Project number #{num} is in an
unrecognizable format"
end
@proj = sprintf("%06d",n)
end
===============================================================
The following test case does work
1 tests, 2 assertions, 0 failures, 0 errors
===============================================================
def testProj
@prj.proj='68906'
# assert_equal("068906",@prj.proj='68906')
assert_equal(true,@prj.proj=='068906')
assert_equal(false,@prj.proj=='68906')
end
Your time, as always, is appreciated...
dvn