plugin_test.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package main
  2. import (
  3. "testing"
  4. )
  5. func TestCalculateScore(t *testing.T) {
  6. var cardsDealt []string
  7. if res := calculateScore(cardsDealt); res != 0 {
  8. t.Log("error should be 0, but got", res)
  9. t.Fail()
  10. }
  11. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "queen_of_hearts"}
  12. if res := calculateScore(cardsDealt); res != 12 {
  13. t.Log("error should be 12, but got", res)
  14. t.Fail()
  15. }
  16. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "ace_of_clubs", "ace_of_spades"}
  17. if res := calculateScore(cardsDealt); res != 14 {
  18. t.Log("error should be 14, but got", res)
  19. t.Fail()
  20. }
  21. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "ace_of_clubs", "ace_of_spades", "7_of_hearts"}
  22. if res := calculateScore(cardsDealt); res != 21 {
  23. t.Log("error should be 21, but got", res)
  24. t.Fail()
  25. }
  26. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "ace_of_clubs", "ace_of_spades", "2_of_hearts", "3_of_spades", "2_of_diamonds"}
  27. if res := calculateScore(cardsDealt); res != 21 {
  28. t.Log("error should be 21, but got", res)
  29. t.Fail()
  30. }
  31. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "ace_of_clubs", "ace_of_spades", "queen_of_hearts"}
  32. if res := calculateScore(cardsDealt); res != 14 {
  33. t.Log("error should be 14, but got", res)
  34. t.Fail()
  35. }
  36. cardsDealt = []string{"ace_of_hearts", "ace_of_spades", "queen_of_hearts", "ace_of_clubs", "ace_of_spades"}
  37. if res := calculateScore(cardsDealt); res != 14 {
  38. t.Log("error should be 14, but got", res)
  39. t.Fail()
  40. }
  41. cardsDealt = []string{"2_of_clubs", "6_of_clubs", "3_of_clubs", "2_of_hearts", "8_of_diamonds"}
  42. if res := calculateScore(cardsDealt); res != 21 {
  43. t.Log("error should be 21, but got", res)
  44. t.Fail()
  45. }
  46. cardsDealt = []string{"queen_of_clubs", "queen_of_diamonds"}
  47. if res := calculateScore(cardsDealt); res != 20 {
  48. t.Log("error should be 20, but got", res)
  49. t.Fail()
  50. }
  51. cardsDealt = []string{"queen_of_clubs", "queen_of_diamonds", "ace_of_hearts"}
  52. if res := calculateScore(cardsDealt); res != 21 {
  53. t.Log("error should be 21, but got", res)
  54. t.Fail()
  55. }
  56. cardsDealt = []string{"2_of_clubs", "3_of_diamonds", "ace_of_hearts", "queen_of_diamonds", "ace_of_clubs", "4_of_hearts"}
  57. if res := calculateScore(cardsDealt); res != 21 {
  58. t.Log("error should be 21, but got", res)
  59. t.Fail()
  60. }
  61. }