2
0

side_test.go 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. for _, tt := range tests {
  36. t.Run("TestSideFromString", func(t *testing.T) {
  37. got, err := SideFromString(tt.arg)
  38. if (err != nil) != tt.wantErr {
  39. t.Errorf("SideFromString() error = %v, wantErr %v", err, tt.wantErr)
  40. return
  41. }
  42. if got != tt.want {
  43. t.Errorf("SideFromString() got = %v, want %v", got, tt.want)
  44. }
  45. })
  46. }
  47. }