2017-03-19 13:50:32 +01:00
|
|
|
import unittest
|
2017-04-27 18:10:59 +02:00
|
|
|
|
2017-03-19 13:50:32 +01:00
|
|
|
from isogram import is_isogram
|
|
|
|
|
|
|
|
|
|
|
2018-08-29 10:03:47 -04:00
|
|
|
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.5.0
|
2017-03-19 13:50:32 +01:00
|
|
|
|
2018-06-13 09:12:09 -04:00
|
|
|
class IsogramTest(unittest.TestCase):
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
def test_empty_string(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram(""), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
def test_isogram_with_only_lower_case_characters(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("isogram"), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
def test_word_with_one_duplicated_character(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("eleven"), False)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
2018-08-09 09:17:11 -04:00
|
|
|
def test_word_with_one_duplicated_character_from_end_of_alphabet(self):
|
|
|
|
|
self.assertIs(is_isogram("zzyzx"), False)
|
|
|
|
|
|
2017-03-19 13:50:32 +01:00
|
|
|
def test_longest_reported_english_isogram(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("subdermatoglyphic"), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
def test_word_with_duplicated_character_in_mixed_case(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("Alphabet"), False)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
2018-08-29 10:03:47 -04:00
|
|
|
def test_word_with_duplicated_letter_in_mixed_case_lowercase_first(self):
|
|
|
|
|
self.assertIs(is_isogram("alphAbet"), False)
|
|
|
|
|
|
2017-03-19 13:50:32 +01:00
|
|
|
def test_hypothetical_isogrammic_word_with_hyphen(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("thumbscrew-japingly"), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
2017-10-25 19:17:06 +05:30
|
|
|
def test_isogram_with_duplicated_hyphen(self):
|
|
|
|
|
self.assertIs(is_isogram("six-year-old"), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
def test_made_up_name_that_is_an_isogram(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("Emily Jung Schwartzkopf"), True)
|
2017-03-19 13:50:32 +01:00
|
|
|
|
2017-04-27 18:10:59 +02:00
|
|
|
def test_duplicated_character_in_the_middle(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("accentor"), False)
|
2017-04-27 18:10:59 +02:00
|
|
|
|
2017-10-25 19:17:06 +05:30
|
|
|
# Additional tests for this track
|
|
|
|
|
|
2017-08-20 14:31:37 -04:00
|
|
|
def test_isogram_with_duplicated_letter_and_nonletter_character(self):
|
2017-10-14 12:28:50 +00:00
|
|
|
self.assertIs(is_isogram("Aleph Bot Chap"), False)
|
2017-08-20 14:31:37 -04:00
|
|
|
|
2017-03-19 13:50:32 +01:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|