forked from adelyte-chris/compsci201
/
SandwichBarTest.py
38 lines (27 loc) · 1.22 KB
/
SandwichBarTest.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
#!/usr/bin/python
import unittest
from SandwichBar import which_order
class Test(unittest.TestCase):
# Note: test cases are methods that begin with `test` <https://docs.python.org/2/library/unittest.html>
def test_example_1(self):
available = ["ham", "cheese", "mustard"]
order = ["ham cheese"]
value = which_order(available, order)
self.assertEqual(value, 0)
def test_example_2(self):
available = ["cheese", "mustard", "lettuce"]
order = ["cheese ham", "cheese mustard lettuce", "ketchup", "beer"]
value = which_order(available, order)
self.assertEqual(value, 1)
def test_example_3(self):
available = [ "cheese", "cheese", "cheese", "tomato" ]
order = [ "ham ham ham", "water", "pork", "bread", "cheese tomato cheese", "beef" ]
value = which_order(available, order)
self.assertEqual(value, 4)
def test_example_4(self):
available = [ "foo", "bar", "baz", "gazonk", "quux", "bat", "xyzzy", "shme", "hukarz", "grault", "waldo", "bleh" ]
order = [ "kalatehas", "spam eggs", "needle haystack", "bleh blarg", "plugh", "the best sandwich in the universe" ]
value = which_order(available, order)
self.assertEqual(value, -1)
if __name__ == "__main__":
unittest.main()