-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_hw9.py
48 lines (38 loc) · 2.48 KB
/
test_hw9.py
1
2
3
4
5
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
Created on Apr 1, 2015
@author: Brian Borowski
CS115 - Hw 9 Test Script
'''
import unittest
import hw9
class Test(unittest.TestCase):
def test01(self):
self.assertEqual(hw9.questifyAlt([]), [])
self.assertEqual(hw9.questifyAlt(['yeah']), ['yeah?'])
self.assertEqual(hw9.questifyAlt(['yeah', 'really', 'no way']), ['yeah?', 'really?', 'no way?'])
def test02(self):
self.assertEqual(hw9.catenateLoop([]), '')
self.assertEqual(hw9.catenateLoop(['this']), 'this')
self.assertEqual(hw9.catenateLoop(['this', 'function', 'actually', 'works']), 'thisfunctionactuallyworks')
def test03(self):
self.assertEqual(hw9.letterScoreLoop('a', hw9.scrabbleScores), 1)
self.assertEqual(hw9.letterScoreLoop('f', hw9.scrabbleScores), 4)
self.assertEqual(hw9.letterScoreLoop('q', hw9.scrabbleScores), 10)
self.assertEqual(hw9.letterScoreLoop('z', hw9.scrabbleScores), 10)
def test04(self):
self.assertEqual(hw9.wordScoreLoop('', hw9.scrabbleScores), 0)
self.assertEqual(hw9.wordScoreLoop('test', hw9.scrabbleScores), 4)
self.assertEqual(hw9.wordScoreLoop('zebra', hw9.scrabbleScores), 16)
self.assertEqual(hw9.wordScoreLoop('manufacturing', hw9.scrabbleScores), 21)
def test05(self):
self.assertEqual(hw9.wordsWithScoreLambda([], hw9.scrabbleScores), [])
self.assertEqual(hw9.wordsWithScoreLambda(['a'], hw9.scrabbleScores), [['a', 1]])
self.assertEqual(hw9.wordsWithScoreLambda(['python', 'is', 'awesome'], hw9.scrabbleScores), [['python', 14], ['is', 2], ['awesome', 12]])
self.assertEqual(hw9.wordsWithScoreLambda(hw9.aDictionary, hw9.scrabbleScores), [['a', 1], ['am', 4], ['at', 2], ['apple', 9], ['bat', 5], ['bar', 5], ['babble', 12], ['can', 5], ['foo', 6], ['spam', 8], ['spammy', 15], ['zzyzva', 39]])
def test06(self):
self.assertEqual(hw9.wordsWithScoreLoop([], hw9.scrabbleScores), [])
self.assertEqual(hw9.wordsWithScoreLoop(['a'], hw9.scrabbleScores), [['a', 1]])
self.assertEqual(hw9.wordsWithScoreLoop(['python', 'is', 'awesome'], hw9.scrabbleScores), [['python', 14], ['is', 2], ['awesome', 12]])
self.assertEqual(hw9.wordsWithScoreLoop(hw9.aDictionary, hw9.scrabbleScores), [['a', 1], ['am', 4], ['at', 2], ['apple', 9], ['bat', 5], ['bar', 5], ['babble', 12], ['can', 5], ['foo', 6], ['spam', 8], ['spammy', 15], ['zzyzva', 39]])
if __name__ == "__main__":
unittest.main()