bot_test.go 617B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import "testing"
  3. func testParseScore(t *testing.T) {
  4. s := parseScore("[[Image:1.png]][[Image:1.png]][[Image:1.png]][[Image:0.png]][[Image:0.png]]")
  5. if s != "3" {
  6. t.Fail()
  7. }
  8. s = parseScore("[[Image:1.png]][[Image:1.png]]")
  9. if s != "2" {
  10. t.Fail()
  11. }
  12. s = parseScore("{{Rating|3|5}}")
  13. if s != "3" {
  14. t.Fail()
  15. }
  16. s = parseScore("{{Rating|4.5|5}}")
  17. if s != "4.5" {
  18. t.Fail()
  19. }
  20. s = parseScore("**")
  21. if s != "2" {
  22. t.Fail()
  23. }
  24. s = parseScore("4½")
  25. if s != "4.5" {
  26. t.Fail()
  27. }
  28. s = parseScore("1.5")
  29. if s != "1.5" {
  30. t.Fail()
  31. }
  32. s = parseScore("2,5")
  33. if s != "2.5" {
  34. t.Fail()
  35. }
  36. }