side_test.go 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package sentio
  2. import "testing"
  3. func TestSideFromString(t *testing.T) {
  4. tests := []struct {
  5. arg string
  6. want Side
  7. wantErr bool
  8. }{
  9. {
  10. arg: "short",
  11. want: SHORT,
  12. wantErr: false,
  13. },
  14. {
  15. arg: "Short",
  16. want: SHORT,
  17. wantErr: false,
  18. },
  19. {
  20. arg: " short ",
  21. want: SHORT,
  22. wantErr: false,
  23. },
  24. {
  25. arg: "ShOrT",
  26. want: SHORT,
  27. wantErr: false,
  28. },
  29. {
  30. arg: "šhort",
  31. want: -1,
  32. wantErr: true,
  33. },
  34. {
  35. arg: "base",
  36. want: BASE,
  37. wantErr: false,
  38. },
  39. }
  40. for _, tt := range tests {
  41. t.Run("TestSideFromString", func(t *testing.T) {
  42. got, err := ParseSide(tt.arg)
  43. if (err != nil) != tt.wantErr {
  44. t.Errorf("SideFromString() error = %v, wantErr %v", err, tt.wantErr)
  45. return
  46. }
  47. if got != tt.want {
  48. t.Errorf("SideFromString() got = %v, want %v", got, tt.want)
  49. }
  50. })
  51. }
  52. }