Skip to content

Commit

Permalink
Add some extra test cases.
Browse files Browse the repository at this point in the history
This is to ensure that all `second_play_test` cases are covered.
  • Loading branch information
drvinceknight committed Jun 3, 2017
1 parent 294b27c commit 741b300
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions axelrod/tests/strategies/test_lookerup.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ def test_strategy(self):
actions = [(C, C), (C, D), (D, C), (C, D)]
self.versus_test(axelrod.Alternator(), expected_actions=actions)

actions = [(C, D), (D, D), (D, D)]
self.versus_test(axelrod.Defector(), expected_actions=actions)

def test_cooperator_table(self):
lookup_table = {((), (), ()): C}
actions = [(C, D)] * 5
Expand Down
26 changes: 24 additions & 2 deletions axelrod/tests/strategies/test_titfortat.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TestTitFor2Tats(TestPlayer):
def test_strategy(self):
# Will punish sequence of 2 defections but will forgive
opponent = axelrod.MockPlayer(actions=[D, D, D, C, C])
actions = [(C, D), (C, D), (D, D), (D, C), (C, C)]
actions = [(C, D), (C, D), (D, D), (D, C), (C, C), (C, D)]
self.versus_test(opponent, expected_actions=actions)


Expand All @@ -104,6 +104,14 @@ def test_strategy(self):
actions = [(C, D), (D, C), (D, C), (C, D), (D, C)]
self.versus_test(opponent, expected_actions=actions)

actions = [(C, C), (C, C)]
self.versus_test(opponent=axelrod.Cooperator(),
expected_actions=actions)

actions = [(C, D), (D, D), (D, D)]
self.versus_test(opponent=axelrod.Defector(),
expected_actions=actions)


class TestDynamicTwoTitsForTat(TestPlayer):

Expand Down Expand Up @@ -201,6 +209,13 @@ def test_strategy(self):
actions = [(D, C), (C, D)] * 8
self.versus_test(axelrod.TitForTat(), expected_actions=actions)

actions = [(D, C), (C, C), (C, C)]
self.versus_test(axelrod.Cooperator(),
expected_actions=actions)

actions = [(D, D), (D, D), (D, D)]
self.versus_test(axelrod.Defector(), expected_actions=actions)


class TestAntiTitForTat(TestPlayer):

Expand Down Expand Up @@ -238,6 +253,13 @@ def test_strategy(self):
actions = [(C, D), (D, C), (D, C), (D, C), (C, D), (D, C)]
self.versus_test(opponent, expected_actions=actions)

actions = [(C, C), (C, C), (C, C)]
self.versus_test(axelrod.Cooperator(),
expected_actions=actions)

actions = [(C, D), (D, D), (D, D)]
self.versus_test(axelrod.Defector(), expected_actions=actions)


class TestHardTitFor2Tats(TestPlayer):

Expand Down Expand Up @@ -513,7 +535,7 @@ def test_strategy(self):
attrs={"retaliating": False})

opponent = axelrod.MockPlayer(actions=[C, C, C, C, D, C])
actions = [(C, C)] * 4 + [(C, D), (D, C)]
actions = [(C, C)] * 4 + [(C, D), (D, C), (C, C)]
self.versus_test(opponent, expected_actions=actions,
attrs={"retaliating": False})

Expand Down

0 comments on commit 741b300

Please sign in to comment.