2013-07-30 08:42:09 -05:00
|
|
|
import unittest
|
|
|
|
|
|
2018-08-27 13:32:08 -04:00
|
|
|
from bob import hey
|
2014-06-11 15:06:22 +02:00
|
|
|
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2018-08-27 13:32:08 -04:00
|
|
|
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0
|
2013-07-30 08:42:09 -05:00
|
|
|
|
2018-06-13 09:12:09 -04:00
|
|
|
class BobTest(unittest.TestCase):
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_stating_something(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("Tom-ay-to, tom-aaaah-to."), "Whatever.")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_shouting(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("WATCH OUT!"), "Whoa, chill out!")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_shouting_gibberish(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("FCECDFCAAB"), "Whoa, chill out!")
|
2013-07-30 08:42:09 -05:00
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_asking_a_question(self):
|
2013-07-30 08:42:09 -05:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("Does this cryogenic chamber make me look fat?"), "Sure.")
|
2013-07-30 08:42:09 -05:00
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_asking_a_numeric_question(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("You are, what, like 15?"), "Sure.")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_asking_gibberish(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("fffbbcbeab?"), "Sure.")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_talking_forcefully(self):
|
2013-07-30 08:42:09 -05:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("Let's go make out behind the gym!"), "Whatever.")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_using_acronyms_in_regular_speech(self):
|
|
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("It's OK if you don't want to go to the DMV."),
|
2017-03-28 02:56:34 +02:00
|
|
|
"Whatever.")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
2017-03-28 02:56:34 +02:00
|
|
|
def test_forceful_question(self):
|
2013-08-19 10:15:51 -04:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("WHAT THE HELL WERE YOU THINKING?"),
|
2018-01-18 13:34:30 -06:00
|
|
|
"Calm down, I know what I'm doing!"
|
|
|
|
|
)
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_shouting_numbers(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("1, 2, 3 GO!"), "Whoa, chill out!")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
2018-08-27 13:32:08 -04:00
|
|
|
def test_no_letters(self):
|
|
|
|
|
self.assertEqual(hey("1, 2, 3"), "Whatever.")
|
2013-10-19 16:06:22 +02:00
|
|
|
|
2018-08-27 13:32:08 -04:00
|
|
|
def test_question_with_no_letters(self):
|
|
|
|
|
self.assertEqual(hey("4?"), "Sure.")
|
2013-10-19 16:06:22 +02:00
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_shouting_with_special_characters(self):
|
|
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"),
|
2017-03-28 02:56:34 +02:00
|
|
|
"Whoa, chill out!")
|
2013-10-19 16:06:22 +02:00
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_shouting_with_no_exclamation_mark(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("I HATE THE DMV"), "Whoa, chill out!")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_statement_containing_question_mark(self):
|
|
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("Ending with ? means a question."), "Whatever.")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_non_letters_with_question(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey(":) ?"), "Sure.")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_prattling_on(self):
|
|
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("Wait! Hang on. Are you going to be OK?"), "Sure.")
|
2013-07-30 08:42:09 -05:00
|
|
|
|
|
|
|
|
def test_silence(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey(""), "Fine. Be that way!")
|
2013-08-19 10:15:51 -04:00
|
|
|
|
|
|
|
|
def test_prolonged_silence(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey(" "), "Fine. Be that way!")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_alternate_silence(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("\t\t\t\t\t\t\t\t\t\t"), "Fine. Be that way!")
|
2014-10-10 17:29:14 -04:00
|
|
|
|
2017-03-28 02:56:34 +02:00
|
|
|
def test_multiple_line_question(self):
|
2014-08-02 17:05:00 +12:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("\nDoes this cryogenic chamber make me look fat?\nno"),
|
2017-03-28 02:56:34 +02:00
|
|
|
"Whatever.")
|
2013-07-30 08:42:09 -05:00
|
|
|
|
2017-03-28 02:56:34 +02:00
|
|
|
def test_starting_with_whitespace(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey(" hmmmmmmm..."), "Whatever.")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_ending_with_whitespace(self):
|
2014-10-10 17:34:08 -04:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("Okay if like my spacebar quite a bit? "), "Sure.")
|
2017-03-28 02:56:34 +02:00
|
|
|
|
|
|
|
|
def test_other_whitespace(self):
|
2018-08-27 13:32:08 -04:00
|
|
|
self.assertEqual(hey("\n\r \t"), "Fine. Be that way!")
|
2014-10-10 17:34:08 -04:00
|
|
|
|
2017-03-28 02:56:34 +02:00
|
|
|
def test_non_question_ending_with_whitespace(self):
|
2016-07-21 10:49:43 -07:00
|
|
|
self.assertEqual(
|
2018-08-27 13:32:08 -04:00
|
|
|
hey("This is a statement ending with whitespace "),
|
2017-03-28 02:56:34 +02:00
|
|
|
"Whatever.")
|
2016-07-21 10:49:43 -07:00
|
|
|
|
2016-11-29 09:44:47 +01:00
|
|
|
|
2013-07-30 08:42:09 -05:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|