mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Added isPandigital function
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#Python/pyClasses/TestStringAlgorithms.py
|
||||
#Matthew Ellison
|
||||
# Created: 07-21-21
|
||||
#Modified: 07-21-21
|
||||
#Modified: 10-11-21
|
||||
#Tests for my library of number algorithms
|
||||
"""
|
||||
Copyright (C) 2021 Matthew Ellison
|
||||
@@ -52,6 +52,43 @@ class TestStringAlgorithms(unittest.TestCase):
|
||||
answer = StringAlgorithms.isPalindrome(str)
|
||||
self.assertEqual(correctAnswer, answer, "isPalindrome failed the third test")
|
||||
|
||||
def testIsPandigital(self):
|
||||
#Test 1
|
||||
str = "123456789"
|
||||
correctAnswer = True
|
||||
answer = StringAlgorithms.isPandigital(str)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the first test")
|
||||
|
||||
#Test 2
|
||||
str = "123"
|
||||
correctAnswer = True
|
||||
answer = StringAlgorithms.isPandigitalFull(str, 1, 3)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the second test")
|
||||
|
||||
#Test 3
|
||||
str = "123"
|
||||
correctAnswer = False
|
||||
answer = StringAlgorithms.isPandigital(str)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the third test")
|
||||
|
||||
#Test 4
|
||||
str = "123"
|
||||
correctAnswer = False
|
||||
answer = StringAlgorithms.isPandigitalFull(str, 3, 1)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the fourth test")
|
||||
|
||||
#Test 5
|
||||
str = "1"
|
||||
correctAnswer = True
|
||||
answer = StringAlgorithms.isPandigitalFull(str, 1, 1)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the fifth test")
|
||||
|
||||
#Test 6
|
||||
str = "112"
|
||||
correctAnswer = False
|
||||
answer = StringAlgorithms.isPandigitalFull(str, 1, 3)
|
||||
self.assertEqual(correctAnswer, answer, "isPandigital failed the sixth test")
|
||||
|
||||
|
||||
#Run the unit test if the script is called
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user