def test_unique(): start_time = timer() val_1 = is_unique("Hello") # False Case val_2 = is_unique("That isn't possible") # False Case val_3 = is_unique("Safe word") # Success Case val_4 = is_unique( "There once was a man who wore a hat.") # Long False Case end_time = timer() print( str.format("isUnique: {} {} {} {} {}", val_1, val_2, val_3, val_4, end_time - start_time)) assert val_1 == False assert val_2 == False assert val_3 == True assert val_4 == False start_time = timer() val_1 = is_unique_faster("Hello") # False Case val_2 = is_unique_faster("That isn't possible") # False Case val_3 = is_unique_faster("Safe word") # Success Case val_4 = is_unique_faster( "There once was a man who wore a hat.") # Long Case end_time = timer() print( str.format("isUniqueFaster: {} {} {} {} {}", val_1, val_2, val_3, val_4, end_time - start_time)) assert val_1 == False assert val_2 == False assert val_3 == True assert val_4 == False
def test_when_string_is_empty(self): with self.assertRaises(ValueError): q1.is_unique("") with self.assertRaises(ValueError): q1.is_unique(" ")
def test_when_string_is_not_the_right_type(self): with self.assertRaises(TypeError): q1.is_unique(None) with self.assertRaises(TypeError): q1.is_unique(1)
def test_is_unique(s, expected): """ String checked for all unique characters. In: s (str): The string being checked. expected (bool): Telling whether string has all unique characters. """ actual = is_unique(s) assert actual == expected
def test_is_unique(): assert is_unique("test") is False assert is_unique("Test") is True assert is_unique("qwertyuiopasdfghjklzxcvbnm") is True assert is_unique("qwertyuiopasdfghjklzxcvbnmq") is False
def test_helo(self): from is_unique import is_unique self.assertTrue(is_unique("helo"))
def test_is_unique(): assert is_unique("abc") is True assert is_unique("abca") is False assert is_unique("") is True
def test_not_unique_input(self): self.assertFalse(is_unique("Not unique string"))
def test_empty_string(self): self.assertTrue(is_unique(""))
def test_unique_input(self): self.assertTrue(is_unique("Unique Msg"))
def test_when_string_is_right_and_not_empty(self): self.assertEqual(q1.is_unique("hi"), True) self.assertEqual(q1.is_unique("hello world"), False)