def test_stack_is_empty(self): s = util.Stack() self.assertTrue(s.is_empty()) s.push(1) self.assertFalse(s.is_empty()) s.pop() self.assertTrue(s.is_empty())
def test_accepts_variable_inputs(self): s = util.Stack() s.push(*[2, 4, 6]) actual = [] for elem in s: actual.append(elem) self.assertListEqual(actual, [6, 4, 2])
def test_evaluates_to_false_when_empty(self): s = util.Stack() s.push(5) self.assertTrue(s) s.pop() self.assertFalse(s)
def test_gets_size(self): s = util.Stack() s.push(1, 3, 5, 7, 9) self.assertEqual(len(s), 5)