def test_camelcase_sentence(self): self.assertEqual("spacesBefore", camel_case.camel_case("Spaces Before")) self.assertEqual("stringWithNumber", camel_case.camel_case("string with number")) self.assertEqual("uniCodeCharacters", camel_case.camel_case("uni code characters"))
def test_spaces(self): #one space self.assertEqual('helloWorld', camel_case.camel_case('Hello World')) #multiple spaces in front of words self.assertEqual('helloWorld', camel_case.camel_case(' Hello World')) #multiple spaces after words self.assertEqual('helloWorld', camel_case.camel_case('Hello World ')) #mutliple space in front of multiple words self.assertEqual('helloWorldHowAreYou', camel_case.camel_case(' Hello World how are you')) #multiple space after multiple words self.assertEqual('helloWorldHowAreYou', camel_case.camel_case('Hello World how are you '))
def test_rand(self): sol = lambda s: "".join(w.capitalize() for w in s.split(" ")) base = "abcdefghijklmnopqrstuvwxyz" for _ in range(40): s = " ".join("".join(base[randint(0, len(base) - 1)] for l in range(randint(3, 15))) for q in range(randint(1, 15))) self.assertEqual(camel_case(s), sol(s), "It should work for random inputs too")
def test_camelcase_sentence_char_exception(self): with self.assertRaises(ValueError): camel_case.camel_case("*&( **&MM") with self.assertRaises(ValueError): camel_case.camel_case("*()\\") with self.assertRaises(ValueError): camel_case.camel_case("= % /$ #")
def test_camelcase_sentence(self): expected = 'helloWorld' actual = camel_case.camel_case('Hello World') self.assertEqual(expected, actual)
def test_extra_spaces(self): expected = 'helloWorld' actual = camel_case.camel_case('Hello World') self.assertEqual(expected, actual)
def test(self): self.assertEqual(camel_case("test case"), "TestCase") self.assertEqual(camel_case("camel case method"), "CamelCaseMethod") self.assertEqual(camel_case("say hello "), "SayHello") self.assertEqual(camel_case(" camel case word"), "CamelCaseWord") self.assertEqual(camel_case(""), "")
def test_camel_case(): assert camel_case("test case") == "TestCase" assert camel_case("camel case method") == "CamelCaseMethod" assert camel_case("say hello ") == "SayHello" assert camel_case(" camel case word") == "CamelCaseWord" assert camel_case("") == ""
def test_camelcase_sentence(self): self.assertEqual('helloWorld', camel_case.camel_case('Hello World'))
def test_string_with_numbers(self): with self.assertRaises(ValueError): camel_case.camel_case('1532')
def test_empty_string_value_error(self): with self.assertRaises(ValueError): camel_case.camel_case('')
def test_uppercase_lowercase_combos(self): self.assertEqual('helloWorld', camel_case.camel_case('HeLlO WoRlD'))
def test_one_word(self): #one word should return lowercase self.assertEqual('hello', camel_case.camel_case('HELLO'))
def test_empty_string(self): #empty string should return empty string self.assertEqual('', camel_case.camel_case(''))