1
This commit is contained in:
2024-11-30 22:18:55 +08:00
parent ee8bf46701
commit e58e890ccb
2 changed files with 24 additions and 8 deletions

View File

@@ -32,19 +32,33 @@ def test_hand():
print("添加 1条 后的手牌:", hand)
# 测试是否可以碰
assert hand.can_pong("1条") == True, f"测试失败1条应该可以碰"
assert hand.can_pong("3") == False, f"测试失败3条不可以碰"
assert hand.can_peng("1条") == True, f"测试失败1条应该可以碰"
print("可以碰 1条 的牌:", hand.can_peng("1"))
assert hand.can_peng("3条") == False, f"测试失败3条不可以碰"
print("不可以碰 3条 的牌:", hand.can_peng("3条"))
# 测试是否可以杠
assert hand.can_gang("1条") == False, f"测试失败1条不可以杠"
print("不可以杠 1条 的牌:", hand.can_gang("1条"))
assert hand.can_gang("2条") == False, f"测试失败2条不可以杠"
print("不可以杠 2条 的牌:", hand.can_gang("2条"))
# 添加更多牌来形成杠
hand.add_tile("2条")
print("添加牌后手牌:", hand)
hand.add_tile("2条")
print("添加牌后手牌:", hand)
assert hand.can_gang("2条") == False, f"测试失败2条不可以杠" # still not enough for gang
# 添加一张更多的 2条 来形成杠
hand.add_tile("2条")
print("添加一张2条后:", hand)
assert hand.can_gang("2条") == True, f"测试失败2条应该可以杠"
print("所有测试通过!")
# 运行测试
test_hand()