Beispiel #1
0
 def test_sample(self):
     self.assertTrue(
         isPalindrome('''Was it a car
         or a cat
         I saw?'''))
     self.assertFalse(
         isPalindrome('''A man, a plan, 
         a canal, a hedgehog, 
         a podiatrist, 
         Panama!'''))
     self.assertFalse(
         isPalindrome('''Are we not drawn onward, 
         we few, drawn onward to new area?'''))
Beispiel #2
0
 def test_sample(self):
     self.assertTrue(isPalindrome(
         '''Was it a car
         or a cat
         I saw?'''
     ))
     self.assertFalse(isPalindrome(
         '''A man, a plan, 
         a canal, a hedgehog, 
         a podiatrist, 
         Panama!'''
     ))
     self.assertFalse(isPalindrome(
         '''Are we not drawn onward, 
         we few, drawn onward to new area?'''
     ))
 def testIsPalindromeNumber(self):
     self.assertTrue(p.isPalindrome(1), '1 is a palindrome number but isPalindrome(1) returned false.')
     self.assertFalse(p.isPalindrome(10), '10 is not a palindrome but isPalindrome(10) returned true.')
     self.assertTrue(p.isPalindrome(11), '11 is a palindrome but isPalindrome(11) returned false.')
     self.assertFalse(p.isPalindrome(12), '12 is a palindrome but isPalindrome(12) returned true.')
     self.assertTrue(p.isPalindrome(101), '101 is a palindrome but isPalindrome(101) returned false.')
     self.assertFalse(p.isPalindrome(201), '201 is a palindrome but isPalindrome(201) returned true.')
     self.assertTrue(p.isPalindrome(252), '252 is a palindrome but isPalindrome(252) returned false.')
     self.assertTrue(p.isPalindrome(1001), '1001 is a palindrome but isPalindrome(1001) returned false.')
 def test_correctResult(self):
     result = palindrome.isPalindrome(inp)
     for i in range(0, len(inp)):
         if inp[i] != inp[len(inp) - i - 1]:
             correct_result = False
             break
         correct_result = True
     self.assertEqual(result, correct_result)
Beispiel #5
0
def test_correctResult(inp):
    result = palindrome.isPalindrome(inp)
    for i in range(0, len(inp)):
        if inp[i] != inp[len(inp) - i - 1]:
            correct_result = False
            break
        correct_result = True
    assert result == correct_result
    def testPalindrome(self):
        self.assertTrue(palindrome.isPalindrome(1111))
        self.assertTrue(palindrome.isPalindrome(313))
        self.assertTrue(palindrome.isPalindrome(12344321))
        self.assertTrue(palindrome.isPalindrome(1))

        self.assertFalse(palindrome.isPalindrome(1121))
        self.assertFalse(palindrome.isPalindrome(233))
        self.assertFalse(palindrome.isPalindrome(5678))
        self.assertFalse(palindrome.isPalindrome(1234))
 def test_1(self):
     self.assertEqual(palindrome.isPalindrome("dad dad"), "is a palindrome")
def test_3():
    assert palindrome.isPalindrome(1001) == 1
def test_1():
    assert palindrome.isPalindrome("dad dad") == "is a palindrome"
 def test_3(self):
     self.assertEqual(palindrome.isPalindrome(1001), 1)
 def test_odd_length_strings(self):
   for c in string.ascii_letters:
     self.assertTrue(isPalindrome("{0}{1}{0}".format(c, random.choice(string.ascii_letters))))
   for (c1, c2) in [(c1, c2) for c1 in string.ascii_letters for c2 in string.ascii_letters if c1 != c2]:
     self.assertFalse(isPalindrome("{0}{2}{1}".format(c1, c2, random.choice(string.ascii_letters))))
Beispiel #12
0
def test_isPalindrome_empty():
	assert_false( palindrome.isPalindrome("") )
Beispiel #13
0
 def test_two_words(self):
     self.assertTrue(isPalindrome('one eno'))
     self.assertTrue(isPalindrome('one eno!'))
     self.assertTrue(isPalindrome('onetwothree eerhtowteno'))
     self.assertFalse(isPalindrome('one owt'))
Beispiel #14
0
 def test_one_word(self):
     self.assertTrue(isPalindrome('abba'))
     self.assertTrue(isPalindrome('abBA'))
     self.assertTrue(isPalindrome('ABBA!!'))
     self.assertFalse(isPalindrome('abab'))
     self.assertFalse(isPalindrome('abab?'))
 def test_single_chars(self):
   for c in string.ascii_letters:
     self.assertTrue(isPalindrome(c))
 def test_odd_length_decimals(self):
   for i in range(1, 10):
     self.assertTrue(isPalindrome(i + 10 * random.randrange(10) + 100 * i))
   for i in [x + 10 * random.randrange(10) + 100 * y for x in range(10) for y in range(1, 10) if x != y]:
     self.assertFalse(isPalindrome(i), "{0} tested as a palindrome but shouldn't have (probably).".format(i))
 def test_greentea(self):
     self.assertEqual(palindrome.isPalindrome("greentea"), False)
 def test_len_1_decimals(self):
   for i in range(10):
     self.assertTrue(isPalindrome(i))
 def test_fooffoof(self):
     self.assertEqual(palindrome.isPalindrome("baMbmaB"), True)
Beispiel #20
0
def test_PalindromeCaps():
    assert palindrome.isPalindrome(
        "DylanNalyD") == True  #shows that I didnt test for cap sensitivity
 def topic(self):
     return isPalindrome("MaDAm")
 def test_even_length_strings(self):
   for c in string.ascii_letters:
     self.assertTrue(isPalindrome("{0}{0}".format(c)))
   for (c1, c2) in [(c1, c2) for c1 in string.ascii_letters for c2 in string.ascii_letters if c1 != c2]:
     self.assertFalse(isPalindrome("{0}{1}".format(c1, c2)))
Beispiel #23
0
def test_is_palindrome():
    assert palindrome.isPalindrome("Nick") == False
Beispiel #24
0
 def test_trivial(self):
     self.assertTrue(isPalindrome(''))
     self.assertTrue(isPalindrome('a'))
     self.assertTrue(isPalindrome('Q'))
     self.assertTrue(isPalindrome('b?'))
     self.assertTrue(isPalindrome('t '))
 def test_2(self):
     self.assertEqual(palindrome.isPalindrome("my name is katie"),
                      "is not a palindrome")
Beispiel #26
0
 def test_notPalindrome(
     self
 ):  #This test should fail. I am running this test because I want to make sure that my palindrome
     #Test works for things that are not palindromes.
     self.assertEqual(palindrome.isPalindrome("Jacob Eckroth"), False)
 def test_4(self):
     self.assertEqual(palindrome.isPalindrome(12), 1)
Beispiel #28
0
 def test_wrongType(self):
     self.assertEqual(
         palindrome.isPalindrome(5), False
     )  #This should return false because 5 is not a string, and therefore not a palindrome.
def test_2():
    assert palindrome.isPalindrome("my name is katie") == "is not a palindrome"
Beispiel #30
0
 def test_empty(
     self
 ):  #This test should succeed because an empty string is a palindrome.
     self.assertEqual(palindrome.isPalindrome(""), True)
def test_4():
    assert palindrome.isPalindrome(12) == 1
Beispiel #32
0
 def test_for_isPalindrome(self):
     self.assertEqual(isPalindrome('abc'),0)
     self.assertEqual(isPalindrome('abcba'),1)
     self.assertEqual(isPalindrome('123454321'),1)
     self.assertEqual(isPalindrome('-1'),0)
     self.assertEqual(isPalindrome('0'),1)
# Last update: 18 August 2014

# Tester program for the Plan-Composition Study Problems

from rainfall import rainfall
from palindrome import isPalindrome
from shoppingdiscount import checkout
from sumofsquares import sumOfSquares
from sumovertable import sumLargest
from lengthoftriples import maxTripleLength

print( rainfall( [1, -2, 5, -999, 8] ) )

print()

print( isPalindrome( "a man, a plan, a canal: Panama" ) )
print( isPalindrome( "abca" ) )

print()

print( checkout( [ ("shoes", 25), ("bag", 50), ("shoes", 85), ("hat", 15) ] ) )

print()

print( sumOfSquares( 4 ) )

print()

print( sumLargest( [ [1,7,5,3], [20], [6,9] ] ) )

print()
def test_palindrome2():
    assert palindrome.isPalindrome("12321") == True
Beispiel #35
0
#!/usr/local/bin/python3

import argparse
import palindrome

parser = argparse.ArgumentParser()
parser.add_argument("text_to_check")
args = parser.parse_args()

if args.text_to_check.isalpha():
    print(palindrome.isPalindrome(args.text_to_check))
else:
    print("Please no numbers or special characters in your text")
def test_palindrome3():
    assert palindrome.isPalindrome("Hello World!") == False
 def test_bambmab(self):
     self.assertEqual(palindrome.isPalindrome("bambmab"), True)
def test_palindrome4():
    assert palindrome.isPalindrome(10) == "Not a valid string"
Beispiel #39
0
def test_isPalindrome_dave():
	assert_false( palindrome.isPalindrome("DAVE") )
def test_palindrome5():
    assert palindrome.isPalindrome("Hello World!") == True
Beispiel #41
0
def test_isPalindrome_abcba():
	assert_true( palindrome.isPalindrome("ABCBA") )
def test_palindrome1():
    assert palindrome.isPalindrome("racecar") == True
 def topic(self):
     return isPalindrome("RiSe-To_VoT$e, Sir!")
Beispiel #44
0
def test_palindromeTrue():
    assert palindrome.isPalindrome("DylannalyD") == True