Esempio n. 1
0
 def test_findnumberlist_aggressive(self):
     i, j = random.randint(1, 10000), random.randint(1, 10000)  # Generate two numbers from 1 --> 10,000.
     if j < i:  # In a few moments, we will assume that i < j. If otherwise, we need to change order.
         i, j = j, i  # In case they were ordered "wrong" (50/50 chance), flip the ordering.
     randomized_numberlist = list(range(i,j))  # Create range() object, then list() it because list is input spec.
         # The list() method should actually be unnecessary above, but it is technically the expected input.
     trusted_wordlist = fizzbuzz_translator(randomized_numberlist)  # Use q1 function.
         # This gives us a trusted wordlist of what should come out.
     result_numberlist = q2.findnumberlist(trusted_wordlist)  # What comes out of the q2 function we're testing.
     compare_wordlist = fizzbuzz_translator(result_numberlist)  # Use q1 again so we can do a comparison.
     self.assertEqual(compare_wordlist, trusted_wordlist)  # Compare the trusted version with q2 function result.
     ##############
     #  Second portion: additionally, it should be that the result_numberlist was no longer than the randomized one.
     self.assertLessEqual(len(result_numberlist), len(randomized_numberlist))
Esempio n. 2
0
 def test_findnumberlist_short3(self):  # Yet another test on a short wordlist.
     list_of_words = ['fizz', 'fizzbuzz', 'fizz']
     expected_result = [12, 13, 14, 15, 16, 17, 18]  # Manually checked to be correct.
     actual_result = q2.findnumberlist(list_of_words)
     self.assertEqual(actual_result, expected_result)
Esempio n. 3
0
 def test_findnumberlist_short2(self):  # Another test on a short wordlist.
     list_of_words = ['fizz']
     expected_result = [3]  # Manually checked to be correct.
     actual_result = q2.findnumberlist(list_of_words)
     self.assertEqual(actual_result, expected_result)
Esempio n. 4
0
 def test_findnumberlist_empty(self):  # Test on an impossible wordlist, should return an empty list.
     list_of_words = ['fizzbuzz', 'fizzbuzz']
     expected_result = []
     actual_result = q2.findnumberlist(list_of_words)
     self.assertEqual(actual_result, expected_result)
Esempio n. 5
0
 def test_findnumberlist_long(self):  # Test on a long wordlist.  (Well "long" for certain rather short lengths.)
     list_of_words = ['fizz', 'fizz', 'buzz', 'fizz', 'fizzbuzz', 'fizz', 'buzz', 'fizz', 'fizz', 'buzz', 'fizz', 'fizzbuzz']
     expected_result = [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]  # Manually checked.
     actual_result = q2.findnumberlist(list_of_words)
     self.assertEqual(actual_result, expected_result)