Last active
August 29, 2015 14:22
-
-
Save SMoni/47ae15d5067b7f6ad84a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IntegerArrayToString | |
def asString | |
return self.join(",") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
require "./IntegerArrayToString.rb" | |
class Suite < Test::Unit::TestCase | |
Array.include IntegerArrayToString | |
def test_GetArrayAsString | |
randomNumber = Random.new.rand(1..100) | |
actual = [randomNumber, randomNumber].asString() | |
expected = "#{randomNumber},#{randomNumber}" | |
assert_equal(expected, actual) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StringToIntegerArray | |
def asArray | |
return self.split(",").map(&:to_i) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
require "./StringToIntegerArray.rb" | |
class Suite < Test::Unit::TestCase | |
String.include StringToIntegerArray | |
def test_GetStringAsArray | |
randomNumber = Random.new.rand(1..100) | |
actual = "#{randomNumber},#{randomNumber}".asArray() | |
expected = [randomNumber,randomNumber] | |
assert_equal(expected, actual) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment