Created
August 5, 2012 00:11
-
-
Save jmontross/3260748 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
# | |
require "test/unit" | |
class String | |
def fun_string! | |
## make it work | |
end | |
end | |
# Test for string question 3 | |
class Test_Myprog < Test::Unit::TestCase | |
def test_working | |
string = "apples" | |
assert_equal(string.fun_string!,"SeLpPa") | |
end | |
end | |
# Question 6 or so | |
class GuessingGame | |
## make it work | |
end | |
class TestGuessingGame < Test::Unit::TestCase | |
def test_returns_false_on_no_guess | |
g = GuessingGame.new(50) | |
# test that it returns false when no guess has been made | |
assert_equal(g.solved?,false) | |
end | |
def test_it_takes_guesses | |
g = GuessingGame.new(50) | |
g.guess(50) | |
# test that it returns true when the guess is equal | |
assert_equal(g.solved?,true) | |
end | |
def test_it_returns_lower_if_guess_is_low | |
g = GuessingGame.new(50) | |
assert_equal(g.guess(40),:low) | |
end | |
def test_it_returns_higher_if_guess_is_high | |
g = GuessingGame.new(50) | |
assert_equal(g.guess(53),:high) | |
end | |
def test_it_returns_equal_if_guess_is_equal | |
g = GuessingGame.new(50) | |
assert_equal(g.guess(50),:equal) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment